How do java.time API determines zone rules changes by the government?

letthefireflieslive :

I don't live in a country using DST.

  1. I save a future LocalDateTime, Offset from UTC and ZoneId in DB
  2. Government of that zone changes DST rules
  3. That future time comes, I will retrieve the LocalDateTime in that zone

If I apply ZoneId and Offset to get the LocalDateTime in that zone, how does java.time API get this correctly? How does it know that the government changes the rules? Does it fetch update from the internet?

Aleksei Budiak :

Timezone updates usually come with JRE updates. Whenever the timezone of some particular territory is changed, this information is included into the next version of JRE.

Here you can find some information on the timezone data for JRE/JDK.

If updating JRE/JDK is not an option, TZUpdater tool can be used to update only the timezone data without updating JRE/JDK.

All Java date/time APIs that support timezones implicitly use JRE's timezone data, so the only thing you need to worry about is keeping the timezone data in JRE up-to-date.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=457456&siteId=1