Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-996

Difference in behaviour of java.util.Date(int year, int month, int date) with large negative third parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Won't Fix
    • None
    • None
    • None
    • Windows XP Professional

    Description

      This seem to be a bug in RI .

      The following code

      import java.util.*;

      public class Test {
      public static void main (String[] args) {
      for(int i = -116670; i > -116681; --i )

      { System.out.println("i=" + i + "\t, date=" + new Date(2, 3, i)); }

      }
      }

      Prints in RI:

      i=-116670 , date=Sun Oct 24 00:00:00 MSK 1582
      i=-116671 , date=Sat Oct 23 00:00:00 MSK 1582
      i=-116672 , date=Fri Oct 22 00:00:00 MSK 1582
      i=-116673 , date=Thu Oct 21 00:00:00 MSK 1582
      i=-116674 , date=Wed Oct 20 00:00:00 MSK 1582
      i=-116675 , date=Tue Oct 19 00:00:00 MSK 1582
      i=-116676 , date=Mon Oct 18 00:00:00 MSK 1582
      i=-116677 , date=Sun Oct 17 00:00:00 MSK 1582
      i=-116678 , date=Sat Oct 16 00:00:00 MSK 1582
      i=-116679 , date=Thu Oct 28 00:00:00 MSK 1582
      i=-116680 , date=Wed Oct 27 00:00:00 MSK 1582

      prints in Harmony:

      i=-116670 , date=Sun Oct 24 00:00:00 MSD 1582
      i=-116671 , date=Sat Oct 23 00:00:00 MSD 1582
      i=-116672 , date=Fri Oct 22 00:00:00 MSD 1582
      i=-116673 , date=Thu Oct 21 00:00:00 MSD 1582
      i=-116674 , date=Wed Oct 20 00:00:00 MSD 1582
      i=-116675 , date=Tue Oct 19 00:00:00 MSD 1582
      i=-116676 , date=Mon Oct 18 00:00:00 MSD 1582
      i=-116677 , date=Sun Oct 17 00:00:00 MSD 1582
      i=-116678 , date=Sat Oct 16 00:00:00 MSD 1582
      i=-116679 , date=Fri Oct 05 00:00:00 MSD 1582
      i=-116680 , date=Thu Oct 04 00:00:00 MSD 1582

      Harmony version is a correct calendar switch

      and same functionality rewritten in another way works correctly in both implementations:

      import java.util.*;

      public class Test {
      public static void main (String[] args) {
      Calendar cal = new GregorianCalendar(1582, Calendar.OCTOBER, 29);
      for(int i = 0; i < 20 ; ++i )

      { cal.add(Calendar.HOUR, -24); System.out.println(cal.getTime()); }

      }
      }

      Prints in RI:
      ............
      Sun Oct 17 00:00:00 MSK 1582
      Sat Oct 16 00:00:00 MSK 1582
      Fri Oct 05 00:00:00 MSK 1582
      Thu Oct 04 00:00:00 MSK 1582
      ......

      Prints in Harmony:
      .......
      Sun Oct 17 00:00:00 MSD 1582
      Sat Oct 16 00:00:00 MSD 1582
      Fri Oct 05 00:00:00 MSD 1582
      Thu Oct 04 00:00:00 MSD 1582
      .......

      Attachments

        Activity

          People

            zakha Alexei Zakharov
            aluht Anton Luht
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: