Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I update the timezone information for the OpenJDK?

How do I update the timezone information for the OpenJDK? Oracle puts out tzupdater but that is bound by their license so I don't want to use it. I'm looking for an open source alternative that will allow me to just update the timezone information and not the entire JRE.

like image 620
MonkBen Avatar asked Mar 17 '15 14:03

MonkBen


People also ask

How do I change the TimeZone in Java?

You can make use of the following DateFormat. SimpleDateFormat myDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); myDate. setTimeZone(TimeZone. getTimeZone("UTC")); Date newDate = myDate.

What is the default TimeZone in Java?

According to javadoc the java. util. Date class represents number of milliseconds since the standard base time known as "the epoch", namely 1 January 1970, 00:00:00 GMT.

How do I get JVM TimeZone?

By default, the JVM reads time zone information from the operating system and stores it in the TimeZone class. To get the default time zone set in the JVM using the method TimeZone. getDefault() . To get the list of all supported timezones, use the method TimeZone.


1 Answers

Azul recently published an open source tool to update TZ data: https://www.azul.com/products/open-source-tools/ziupdater-time-zone-tool/

It works similar to Oracle tzupdater, but has open source (GPLv2 License) license.

Usage: apply it to IANA data package using Java which you want to update:

$JAVA_HOME/bin/java -jar ziupdater.jar -l file://[path]/tzdata.tar.gz

By this command you will apply changes to timezone to your Java installation.


What does it mean?

Consider next situation: you installed Java a year ago and later a government of certain country changed their laws, e.g. cancelled DST. Your Java installation doesn't know about that yet and may handle time incorrectly for that particular region. Updating timezone data solves that.

like image 87
Sergey Grinev Avatar answered Oct 12 '22 06:10

Sergey Grinev