Java Europe / Minsk time zone

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 GMT 3 Europe / Minsk time zone on my computer

If I run this program with the latest version of JDK6, I see it show me that my time zone in Java is Venezuela standard time GMT 4.30. If I run it on the latest version of JDK7, it will show me Brazil time zone gmt-3. If I run it on the latest version of jdk8, it will show me Moscow time GMT 3 If I select Volgograd GMT 3 time zone on win7 computer, the program can run normally in all versions of Java Is this an error between JDK and Minsk time zone?

Solution

The problem is that there is no dedicated European / Minsk time zone until 2014 (at least in Windows)

It follows several changes in DST and time zone laws in Russia and Belarus after 2011 and 2014

Refer to the corresponding jdk-8017129 and jdk-8067758 questions

These changes have been considered in the latest java version Older jdks and jres may need to be patched through the timezone updater tool

The operating system time zone settings must also be updated In the case of windows, this means that you need to install kb2570791 and at least kb2998527 patch

There is an alternative solution that does not require the patch mentioned above Just hard code - duser. Com in the Java command line arguments of the required tool or globally timezone = GMT 3. This will be work fine until the next regulation changes.)

However, switching to the latest Java 8 will also benefit from stability and performance improvements

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>