Search code examples
javadatedatetimejava-timezoneddatetime

Interrogate a ZonedDateTime asking if in standard time or in Daylight Saving Time (DST)


How to ask a java.time.ZonedDateTime object if Daylight Saving Time (DST) applies to its moment or if standard time applies?


Solution

  • @Jon's answer is good. Just want to mention there is ZoneRules#isDaylightSavings available.

    ZonedDateTime zdt = ...;
    ZoneRules rules = zdt.getZone().getRules();
    boolean isDst = rules.isDaylightSavings(zdt.toInstant());
    

    And possible duplicate question here.