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

java.text.DateFormat.format(Date) always uses PST instead of local time zone

XMLWordPrintable

    • 1.1fcs
    • generic
    • generic
    • Not verified


      masayoshi.okutsu@Eng 1997-01-13
      The following has been reported by Toshiba.
      ----
      Description:
        java.text.DateFormat.format(Date) always uses PST instead of
      local time zone in japanese environment.

      for example:
      public class DateTest {
        public static void main(String args[]) {
          System.out.println(java.text.DateFormat.getDateTimeFormat().format(new
      Date(0L)));
        }
      }

      prints '69/12/31 16:00:00' in japanese environment.
        In japan, the Epoch is '70/01/01 09:00:00 GMT+0900'.

      Cause:
        JDK-1.1beta2 and current release has no DateFormatZoneData for Japanese,
      java runtime uses US English version of that.

        java.text.DateFormat#private getDefault(int, Locale) method, line 554:
      ...
                  result.setCalendar(Calendar.getDefault((SimpleTimeZone)
                                     TimeZone.getTimeZone(data.zoneStrings[0][0]),
                                     desiredLocale));
      ...
      where data is an DateFormatData, gets TimeZone from
       data.zoneStrings[0][0]. So DateFormat gets its TimeZone by
       getTimeZone("PST"), and it drives DateFormat#format()
       to print time in PST.

            bcbeck Brian Beck (Inactive)
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: