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

TimeZone broken at MIDNIGHT

XMLWordPrintable

    • 1.2fcs
    • generic, sparc
    • generic, solaris_2.5
    • Not verified



      Name: bb33257 Date: 07/31/98


      The TimeZone code fails to handle transitions at MIDNIGHT
      correctly. This will show up both in custom zones and also
      the system zones for Syria (Asia/Damascus), Israel
      (Asia/Jerusalem), Pacific/Rarotonga, and America/Asuncion.

      In the following output, the time should transition from
      Sept 30 23:00 Daylight to
      Sept 30 23:00 Standard to
      Oct 1 0:00 Standard

      Instead, here is the test output:
      0: Wed Sep 30 22:00:00 GMT+03:00 1998
      1: Wed Sep 30 23:00:00 GMT+03:00 1998
      2: Thu Oct 01 00:00:00 GMT+03:00 1998 <- wrong
      3: Thu Oct 01 00:00:00 GMT+02:00 1998
      4: Thu Oct 01 01:00:00 GMT+02:00 1998

      Once this is fixed, additional code must be added to make
      SimpleTimeZone understand leap years; currently, it fails to
      do so. If it does not add this capability, certain days
      (such as February 29, 2000) will be handled incorrectly.

      Here is the test.

      import java.util.*;
      public class bug2 {
          public static void main(String[] args) {
              TimeZone tz = TimeZone.getTimeZone("Asia/Damascus");
              TimeZone.setDefault(tz);
              Date d = new Date(98, Calendar.SEPTEMBER, 30, 22, 0);
              for (int i=0; i<5; ++i) {
                  System.out.println("" + i + ": " + d);
                  d = new Date(d.getTime() + 3600000);
              }
          }
      }

      ======================================================================

            aliusunw Alan Liu (Inactive)
            bcbeck Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: