Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6609357

(cal) HOUR and HOUR_OF_DAY fields of Calender Object are not syncronized in Java 1.5

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 5.0
    • core-libs

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The HOUR and HOUR_OF_DAY fields of the calendar object are not synchronized when we try to roll any one of the fields. This is happening only in Java 1.5 but not in earlier versions.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the sample test case in JDK 1.5 and observe the output.
      Run the same test case in JDK 1.4 and observe the output. Its synchronized in JDK1.4 but not in JDK 1.5

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The HOUR and HOUR_OF_DAY fields should be synchronized. If the HOUR_OF_DAY field value is 20 after rolling, the HOUR field value shoule be 8
      ACTUAL -
      The HOUR field is not getting updated when we try to roll the HOUR_OF_DAY field of the calendar object.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.text.DateFormat;
      import java.text.SimpleDateFormat;

      import java.util.Calendar;
      import java.util.Date;

      public class DateTest
      {
        public static void main (String[] args)
        {
          DateFormat f = new SimpleDateFormat("h");
          Calendar c = Calendar.getInstance();
          c.roll(Calendar.HOUR_OF_DAY, true);
          Date date = c.getTime();
          f.setCalendar(c);
          System.out.println(date);
          System.out.println(f.format(date));
          System.out.println("=================");
          System.out.println(c.get(Calendar.HOUR));
          System.out.println(c.get(Calendar.HOUR_OF_DAY));
        }
      }

      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              okutsu Masayoshi Okutsu
              okutsu Masayoshi Okutsu
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: