JDK-4345790 : Singapore Timezone not recognized by java
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.2.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2000-06-15
  • Updated: 2000-06-19
  • Resolved: 2000-06-19
Related Reports
Duplicate :  
Relates :  
Description
The Singapore Timezone does not appear to be recognized by java.

For example, take this test program (partly stolen from another bug report):

import java.util.Date;
import java.util.TimeZone;
 
public class date {
    public static void main(String argv[]) {
        Date d = new Date();
        System.out.println("java date: " + d.toString());
        System.out.println("java timezone: " + TimeZone.getDefault().getID());
    }
}

Testing with Solaris_JDK_1.2.1_04c and Solaris_JDK_1.2.1_03a, we get this:

$ TZ=Singapore;export TZ
$ date
Thu Jun 15 22:36:41 SGT 2000
$ java date
java date: Thu Jun 15 22:36:45 CST 2000
java timezone: Asia/Shanghai

It comes up with China Standard Time, which is the same offset.

If we explicitly tell java the timezone, we get this:

$ java -Duser.timezone=Asia/Singapore date
java date: Thu Jun 15 22:37:45 GMT+08:00 2000
java timezone: Asia/Singapore


For a workaround, we recompiled the DateFormatZoneData_en_US.class file and put it in /usr/java/jre/classes/java/text/resources.  (See workaround for changes).  We can get the timezone abbreviation to come up correctly, but only if we explicitly set the user.timezone.

$ TZ=Singapore;export TZ 
$ java date
java date: Thu Jun 15 22:54:27 CST 2000
java timezone: Asia/Shanghai
$ java -Duser.timezone=Asia/Singapore date
java date: Thu Jun 15 22:54:46 SGT 2000
java timezone: Asia/Singapore

Comments
WORK AROUND Add the following lines to DateFormatZoneData_en_US.java: {"SGT", "Singapore Time", "SGT", "Singapore", "CDT" }, {"Asia/Singapore", "Singapore Time", "SGT", "Singapore Time", "CDT" }, If you are not in the C or en_US locale, modify the file related to your locale. I am not sure what the Daylight string is supposed to be for Singapore, so I left CDT there. I am probably wrong. Compile the new file and put it in /usr/java/jre/classes/java/text/resources/ateFormatZoneData_en_US.class Anytime you run the jvm, pass it the argument -Duser.timezone=Asia/Singapore (Note: for Netscape Enterprise Server/Iplanet webserver, add the following line to the jvm12.conf user.timezone=Asia/Singapore )
11-06-2004

EVALUATION The time zone mapping problem has been fixed in Kestrel (1.3). The time zone name/abbreviation problem is a dup of 4112924. masayoshi.okutsu@Eng 2000-06-19
19-06-2000