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

(cal) Calendar.set(DST_OFFSET,0) behaves differently in 1.3 vs 1.4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs

      FULL PRODUCT VERSION :
      1.3:
      java version "1.3.1_10"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_10-b03)
      Java HotSpot(TM) Client VM (build 1.3.1_10-b03, mixed mode)

      1.4:
      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Fedora Core release 1 (Yarrow): Linux david 2.4.22-1.2199.nptlsmp #1 SMP Wed Aug 4 11:48:29 EDT 2004 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      On some of our production systems, the upgrade from jdk1.3 to jdk1.4 have a problem with the DST in the Calendar class.

      We used the Calender set method with arguments DST_OFFSET and 0 to let the underlying OS handle dst:

      cal = Calendar.getInstance(Locale.GERMANY);
      cal.set(Calendar.DST_OFFSET,0);

      In jdk1.3 all went well. In jdk1.4 the time in the calendar object is advanced one hour, every time the method is called!?

      So, in jdk1.4, calling the set method with those arguments, say, 4 times, advanced the time of the object with 4 hours. Clearly, this can not be right.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Java code: TestDST.java, see below


      $ /usr/java/jdk1.3/bin/javac TestDST.java
      $ /usr/java/jdk1.3/bin/java TestDST
      -- gives the correct time, 10 times
      $ /usr/java/jdk1.4/bin/javac TestDST.java
      $ /usr/java/jdk1.4/bin/java TestDST
      -- shows the time incrementing 1 hour a step


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected to see the same results with 1.4 as I saw with 1.3
      ACTUAL -
      Thu Aug 19 19:50:44 CEST 2004
      Thu Aug 19 20:50:44 CEST 2004
      Thu Aug 19 21:50:44 CEST 2004
      Thu Aug 19 22:50:44 CEST 2004
      Thu Aug 19 23:50:44 CEST 2004
      Fri Aug 20 00:50:44 CEST 2004
      Fri Aug 20 01:50:44 CEST 2004
      Fri Aug 20 02:50:44 CEST 2004
      Fri Aug 20 03:50:44 CEST 2004
      Fri Aug 20 04:50:44 CEST 2004


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Calendar;
      import java.util.Locale;

      public class TestDST {
          static public void main(String[] args) {
              Calendar cal = Calendar.getInstance(Locale.GERMANY);
              for (int i = 0; i < 10; ++i) {
                  cal.set(Calendar.DST_OFFSET,0);
                  System.out.println(cal.getTime());
              }
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      We've put a test on the System.getProperty("java.version") in our code.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: