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

SimpleDateFormat.parse(String) is an hour off for Australia EST TZ

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.4.1
    • core-libs
    • b37
    • x86
    • windows_xp



      Name: jl125535 Date: 04/09/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Windows TimeZone = "(GMT+10:00) Canberra, Melbourne, Sydney"
      Automatically adjust for daylight saving checkbox selected.

      A DESCRIPTION OF THE PROBLEM :
      When using a SimpleDateFormat with a pattern of "yyyy.MM.dd
      G HH:mm:ss.SSS z" to parse a String of format "2003.01.13 AD
      11:10:00.802 EST" SimpleDateFormat.parse(String) returns an
      incorrect Date.

      The Time field is always one hour out.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Set the Windows Timezone to the Sydney Timezone.
      2. Ensure the "Automatically adjust for daylight saving"
      checkbox is selected.
      3. Compile and run provided java source.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      What I'm expecting is the returned Date be the same as the
      input Date/Time String, as both the input timezone (EST) and
      the machines timezone are the some.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Date;
      import java.text.SimpleDateFormat;

      public class Test {
          public static void main (String args[]) {
              try {
                  String attr = "2003.01.13 AD 11:10:00.802 EST";
                  System.out.println("attr = " + attr);

                  String DATE_TIME_PATTERN = "yyyy.MM.dd G HH:mm:ss.SSS z";
                  SimpleDateFormat dfDeptDate =
                      new SimpleDateFormat(DATE_TIME_PATTERN);

                  Date parsedDate = dfDeptDate.parse(attr);
                  System.out.println("parsedDate = " + parsedDate);

              } catch (Exception e) {
                  e.printStackTrace();
              }
              System.out.println("done.");
              System.exit(0);
          }
      }

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

      CUSTOMER WORKAROUND :
      De-selecting the "Automatically adjust for daylight saving"
      checkbox on the Windows Timezone dialog.
      (Review ID: 179963)
      ======================================================================

            okutsu Masayoshi Okutsu
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: