I have an instance of Java which seems to be using a completely incorrect time zone. Instead of using the Australia/Sydney time zone which Windows is using, it is using the America/Caracas time zone.
I checked the Windows time through the system clock firstly, then checked HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/
and ControlSet001
, ControlSet002
. All are set to a Sydney time zone.
Does anybody know if this is a bug in Java, or if it is referring to a time set elsewhere?
Java version is 1.6.0_06
Ensure you set the timezone for the JVM when starting the application:
-Duser.timezone="Australia/Sydney"
Check information on the following link:
http://techtavern.wordpress.com/2010/04/15/java-and-incorrect-timezone-on-windows-xp/
It shows, that there is a bug in JVM, causing reading incorrect default timezone from windows registry. There is no bug fix yet.
You should update your JRE/SDK, but TZUpdater may be sufficient.
Try in your app to get default timezone, or set timezone manually (commented line).
Little example of mine:
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
Locale locale = Locale.getDefault();
TimeZone localTimeZone = TimeZone.getDefault();
//TimeZone localTimeZone = TimeZone.getTimeZone("Australia/Sydney");
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale);
dateFormat.setTimeZone(localTimeZone);
Date rightNow = new Date();
System.out.println(locale.toString() + ": " + dateFormat.format(rightNow));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With