I don't live in a country using DST.
- I save a future
LocalDateTime
, Offset from UTC andZoneId
in DB - Government of that zone changes DST rules
- 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?
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.