I wrote the following program:
import sun.security.action.GetPropertyAction;
import java.security.AccessController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z").format(new Date()));
System.out.println(TimeZone.getDefault().getDisplayName());
String country =AccessController.doPrivileged(new GetPropertyAction("user.country"));
System.out.println(country);
String javaHome=AccessController.doPrivileged(new GetPropertyAction("java.home"));
System.out.println(javaHome);
}
}
Then I set a GMT+3 Europe/Minsk timezone on my computer.
If I run this program with JDK6 latest release, I see that it shows me that my timezone in Java is Venezuela standard time GMT+4.30 If I run it on latest JDK7 release, it shows me Brazilian timezone GMT-3, If I run it on latest JDK8 release, it shows me Moskow time GMT+3. If I select a Volgograd GMT+3 timezone on my Win7 computer, the program works correctly in all versions of java. So is it a bug in JDK with Minsk timezone?
The problem is caused by the fact that until 2014 there was no dedicated Europe/Minsk timezone (at least in Windows).
It appeared only after several DST and Timezone laws changes in Russia and Belarus in 2011 and 2014.
See corresponding JDK-8017129 and JDK-8067758 issues.
The changes are already taken into account in latest java releases. Older JDKs and JREs may need to be patched via Timezone Updater Tool.
OS timezone settings also have to be updated. In Windows case it means that you need to have KB2570791 and at least KB2998527 patches installed.
There is also an alternative workaround that doesn't require mentioned above patching.
Just hardcode -Duser.timezone=GMT+3
in java command line parameters of needed tools or globally. This would work fine until next regulations change. )
But switching to the latest Java 8 would benefit also from stability and performance improvements.
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