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

Arbitrarily defined timezones like GMT-11 as GMT+11 are mis-interpreted

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs



      Name: dk106046 Date: 01/12/2004

      The problem stated is that JVM mis-represents arbitrarily defined timezones like GMT-11 as GMT+11.

      import java.util.*;
      public class test {
          public static void main(String args[]) {
              System.out.println( "\nJava default Timezone=" +
                                  TimeZone.getDefault() );

              System.out.println("\n Java date=" +
                                 (new java.util.Date()) );
          }
      }

      A sample run is as follows:

      $ export TZ=GMT-11:00,M8.4.2,M3.2.1
      $
      $ java test

      Java default Timezone=java.util.SimpleTimeZone[id=Custom,offset=39600000,dstSavings=3600000,useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]

       Java date=Wed Jan 07 21:07:08 GMT+11:00 2004
      $
      $date
      Wed Jan 7 21:07:55 GMT 2004

      Notice that it changed GMT-11 to GMT+11.

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

            okutsu Masayoshi Okutsu
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: