How is java.util.TimeZone daylight info updated?

2020-02-15 05:27发布

问题:

I couldn't find a similar question around, so here it goes.

I need to create some alerts and basically identify when a daylight saving time approaches, i.e. next thursday daylight begins

Question How does Timezone knows the correct info?

I ask that because, for instance, in my country - Brazil - the day is defined one year before when it will happen by government. It could potentially not even exist on a specific year. This probably happens in other countries as well.

On Java Doc, the below info can be found:

This method returns a historically correct offset value if an underlying TimeZone implementation subclass supports historical Daylight Saving Time schedule and GMT offset changes

It says it returns a historically correct. But how trustworthy is this method for detecting timezones? Does it depends on regular java updates, does it read from somewhere in Windows, for instance ?

Thanks in advance!

回答1:

The link below explains the official method to update timezones in java

http://www.oracle.com/technetwork/java/javase/tzupdater-readme-136440.html

Basically, download the tool jar and run the command

java -jar tzupdater.jar options