JDK-6583152 : KernelJRE picks wrong TimeZone
  • Type: Bug
  • Component: deploy
  • Sub-Component: deployment_toolkit
  • Affected Version: 6u4
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: x86
  • Submitted: 2007-07-20
  • Updated: 2010-09-08
  • Resolved: 2008-04-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u4 b03Fixed
Description
KernelJRE picks wrong TimeZone. 
For the TimeZone: America/Los_Angeles and Locale :en_US  
KernalJRE picks the ZONE as GMT but it should be PST.

<tescase>
import java.util.*;

public class Foo {
	private static String[] calendar_formats = {
	        "%ts' (0 - 99...?)",
	        "%tz  (-1200 - +1200) ZONE_NUMERIC",
	        "%tZ ZONE (symbol)",
		" DATE_TIME %tc  (Sat Nov 04 12:02:33 EST 1999)",
        };
	public static void main(String... arg) {
		TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
		Locale local = new Locale("en_US");
		Calendar c = new GregorianCalendar(tz, local);
		c.clear();
		c.set(1977, 10, 15);
		StringBuffer sb = new StringBuffer(58);
		Formatter formatter = new Formatter(sb);
		for(String format: calendar_formats) {
		    formatter.format(format+" \n",c);
		}
		System.out.println(sb.toString());
	}
}
</testcase>

<output with kernalJRE>
F:\Kernal>f:\jre1.6.0_02\bin\java Foo
248400000' (0 - 99...?)
+0000  (-1200 - +1200) ZONE_NUMERIC
GMT ZONE (symbol)
 DATE_TIME Tue Nov 15 00:00:00 GMT 1977  (Sat Nov 04 12:02:33 EST 1999)


F:\Kernal>f:\jre1.6.0_02\bin\java -version
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b99)
Java HotSpot(TM) Client VM (build 1.7.0-internal, mixed mode)
</output with kernalJRE>

<NormalJRE>
F:\Kernal>java Foo
248428800' (0 - 99...?)
-0800  (-1200 - +1200) ZONE_NUMERIC
PST ZONE (symbol)
 DATE_TIME Tue Nov 15 00:00:00 PST 1977  (Sat Nov 04 12:02:33 EST 1999)


F:\Kernal>java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b15)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b15, mixed mode)
</NormalJRE>
Simplified testcase:
<testcase>
import java.text.*;
import java.util.*;
class GetInstanceTimeZone {
  public static void main(String[] args) throws Exception {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"));
    TimeZone tz = cal.getTimeZone();
    if (tz.getID() != "PST") {
      System.out.println("Test Failed to getInstance(TimeZone)");
      System.out.println("Expected: PST");
      System.out.println("Actual  : "+tz.getID());
    }
  }
}
</tescase>

Comments
EVALUATION This is due to the lib/zi/... time zone information files not being part of the core download. I tried bundling them together with the Calendar classes, so that they would be present on the system by the time the calendar code is initialized, to no avail. For the time being, the lib/zi/... files have simply been made part of the core.
25-07-2007