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

The default TimeZone for DateFormat is PST

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.3
    • core-libs
    • None
    • sparc
    • solaris_2.5.1

      The following code:
      ------
                      DateFormat dateFormatter =
                      DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.US);
                      TimeZone formatTZ = dateFormatter.getTimeZone();
                      System.out.println("2:Format=" + formatTZ.getID());
      ------
      Produces
      ---------
      2:Format=PST
      --------------
      You get the same result with 1 and 0 argument versions of getTimeInstance().
      The expected result is the TimeZone of the local machine (in my case EST). You can achieve this result by getting the correct default via 'TimeZone.getDefault()' and then use the DateFormat.setTimeZone(). However it is extremely rare that you want to display the time using a TimeZone different from your own, so this logic should be built into the default.



            ssenthilsunw Shanmugam Senthil (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: