Determine DST switching dates (both forward and backward) for timezone in Java?

I understand that you can check if there is a Date inDaylightTime , but how to determine when (or if) this date switches to and from DST? I can iterate over every day and check if it is inDaylightTime, but is there a cleaner solution / method?

+4
source share
1 answer

I would suggest using Joda Time - its DateTimeZone has nextTransition and previousTransition methods.

Please note that transitions may occur for reasons other than DST - a change in standard time or, possibly, a change in the name of the zone. But as you know, one way or another :)

(Joda Time is a much better library of time and time, to be honest).

+2
source

Source: https://habr.com/ru/post/1380229/


All Articles