Harmony
  1. Harmony
  2. HARMONY-996

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      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
      .......

        Activity

        Hide
        Mikhail Markov added a comment -

        API specification says nothing about negative values for the date parameter.
        Also this method is depricated sinse JDK1.1 so they could just simply not "synchronized" in RI with it's replacements (Calendar.set() or GregorianCalendar()).

        Taking this into account, i'm +1 for closing this bug as won't fix.

        Could someone from committers take a look at it? Thanks!

        Show
        Mikhail Markov added a comment - API specification says nothing about negative values for the date parameter. Also this method is depricated sinse JDK1.1 so they could just simply not "synchronized" in RI with it's replacements (Calendar.set() or GregorianCalendar()). Taking this into account, i'm +1 for closing this bug as won't fix. Could someone from committers take a look at it? Thanks!
        Hide
        Alexei Zakharov added a comment -

        I agree with Mikhail. So I will move it to non-bug-diff.

        Show
        Alexei Zakharov added a comment - I agree with Mikhail. So I will move it to non-bug-diff.
        Hide
        Alexei Zakharov added a comment -

        Aha, it is already there. Closed as WON'T FIX.

        Show
        Alexei Zakharov added a comment - Aha, it is already there. Closed as WON'T FIX.

          People

          • Assignee:
            Alexei Zakharov
            Reporter:
            Anton Luht
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development