-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
x86
-
linux
FULL PRODUCT VERSION :
$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 7.10 gutsy i386
EXTRA RELEVANT SYSTEM CONFIGURATION :
out-of-the box install
A DESCRIPTION OF THE PROBLEM :
private static native String getSystemTimeZoneID( "/usr/lib/jvm/java-6-sun-1.6.0.03/jre", "US")
on some machines provide the right timezone America/Los_Angeles on other SYSTEMV/PST8PDT
This native code should be open sourced so it can be reliably fixed. for some reason /etc/localtime is required to be a symbolic link and not an actual file
the problem is described here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416452
get-around when time zone is incorrect:
$ mv /etc/localtime /etc/sunshouldbeopensource
$ ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
in a console java application:
System.out.println(TimeZone.getDefault());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
America/Los_Angeles
ACTUAL -
SYSTEMV/PST8PDT
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
static private void checkTimeZone() {
boolean printID = false;
// you can set a breakpoint on this line, no time zone nothing has happened as of yet
System.out.println("Examining time information: Java modifies system time to obtain local time");
{
TimeZone tz = TimeZone.getDefault(); // a representation of the local time zone
Date date = new Date(); // the local time from System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat();
TimeZone tzUTC = TimeZone.getTimeZone("UTC"); // get the time zone by ID Etc/UTC
sdf.setTimeZone(tzUTC);
// Etc/GMT, Etc/Greenwich, Etc/UTC Etc/Universal Etc/Zulu
if (printID) { // if we want to see the 592 time zone identifiers
int foundTz = 0;
System.out.print("Known time zone identifiers: ");
for (String ss : TimeZone.getAvailableIDs()) {
if (foundTz++ != 0)
System.out.print(", ");
System.out.print(ss);
}
System.out.println();
System.out.println("found " + foundTz + " time zone identifiers");
} // if printID
System.out.println("UTC time is " + sdf.format(date));
System.out.println("the default timezone is " + tz.getDisplayName(true, TimeZone.LONG));
System.out.println("the default timezone ID is " + tz.getID());
System.out.println("useDaylightTime = " + tz.useDaylightTime());
System.out.println("the time is " + date);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
get-around when time zone is incorrect:
$ mv /etc/localtime /etc/sunshouldbeopensource
$ ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime
$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 7.10 gutsy i386
EXTRA RELEVANT SYSTEM CONFIGURATION :
out-of-the box install
A DESCRIPTION OF THE PROBLEM :
private static native String getSystemTimeZoneID( "/usr/lib/jvm/java-6-sun-1.6.0.03/jre", "US")
on some machines provide the right timezone America/Los_Angeles on other SYSTEMV/PST8PDT
This native code should be open sourced so it can be reliably fixed. for some reason /etc/localtime is required to be a symbolic link and not an actual file
the problem is described here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416452
get-around when time zone is incorrect:
$ mv /etc/localtime /etc/sunshouldbeopensource
$ ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
in a console java application:
System.out.println(TimeZone.getDefault());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
America/Los_Angeles
ACTUAL -
SYSTEMV/PST8PDT
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
static private void checkTimeZone() {
boolean printID = false;
// you can set a breakpoint on this line, no time zone nothing has happened as of yet
System.out.println("Examining time information: Java modifies system time to obtain local time");
{
TimeZone tz = TimeZone.getDefault(); // a representation of the local time zone
Date date = new Date(); // the local time from System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat();
TimeZone tzUTC = TimeZone.getTimeZone("UTC"); // get the time zone by ID Etc/UTC
sdf.setTimeZone(tzUTC);
// Etc/GMT, Etc/Greenwich, Etc/UTC Etc/Universal Etc/Zulu
if (printID) { // if we want to see the 592 time zone identifiers
int foundTz = 0;
System.out.print("Known time zone identifiers: ");
for (String ss : TimeZone.getAvailableIDs()) {
if (foundTz++ != 0)
System.out.print(", ");
System.out.print(ss);
}
System.out.println();
System.out.println("found " + foundTz + " time zone identifiers");
} // if printID
System.out.println("UTC time is " + sdf.format(date));
System.out.println("the default timezone is " + tz.getDisplayName(true, TimeZone.LONG));
System.out.println("the default timezone ID is " + tz.getID());
System.out.println("useDaylightTime = " + tz.useDaylightTime());
System.out.println("the time is " + date);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
get-around when time zone is incorrect:
$ mv /etc/localtime /etc/sunshouldbeopensource
$ ln -s /usr/share/zoneinfo/US/Pacific /etc/localtime
- duplicates
-
JDK-6456628 (tz) Default timezone is incorrectly set occasionally on Linux
-
- Closed
-