JDK-4976879 : Arbitrarily defined timezones like GMT-11 as GMT+11 are mis-interpreted
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2004-01-12
  • Updated: 2020-08-06
  • Resolved: 2004-01-13
Related Reports
Duplicate :  
Relates :  
Relates :  
Description

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.

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

Comments
WORK AROUND Unless it's required to support full POSIX TZ, the Etc/GMT* time zone IDs should be used to get common time zones on Solaris and Linux. Another workaround is to use "GMT-11GMT-11" or "UTC-11". Those are unknown to Java and the time zone offset is obtained through libc.
06-08-2004

EVALUATION The full POSIX TZ syntax hasn't been supported yet. Closing this bug report as a duplicate of 4263805. ###@###.### 2004-01-13 Since "GMT-11" isn't a time zone ID supported by the recent Olson public source (zoneinfo), Java parses it as a custom time zone ID specified in the TimeZone API doc. This created an incompatible behavior change since 1.4. To avoid it, time zone ID "Etc/GMT-11" should be used. It's common in Solaris, Linux and Java. $ env TZ=Etc/GMT-11 java -showversion test java version "1.5.0-beta3" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b61) Java HotSpot(TM) Server VM (build 1.5.0-beta3-b61, mixed mode) Java default Timezone=sun.util.calendar.ZoneInfo[id="Etc/GMT-11",offset=39600000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] Java date=Thu Aug 05 15:17:06 GMT+11:00 2004 $ env TZ=Etc/GMT-11 date Thu Aug 5 15:17:08 GMT-11 2004 ###@###.### 2004-08-05
05-08-2004