Created
October 23, 2019 18:16
-
-
Save maikelsperandio/66c7ef1bed202820d60901de45b6ecf1 to your computer and use it in GitHub Desktop.
List the timezone config in the jvm Daylight Saving Time database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
import java.time.Instant; | |
import java.time.ZoneId; | |
import java.time.ZonedDateTime; | |
import java.time.zone.ZoneOffsetTransition; | |
import java.time.zone.ZoneRules; | |
public class TimezoneList { | |
public static void main(String[] args) { | |
System.out.println(new Date()); | |
ZoneId zone = ZoneId.of("America/Sao_Paulo"); | |
ZoneRules rules = zone.getRules(); | |
ZonedDateTime now = ZonedDateTime.now(zone); | |
ZoneOffsetTransition transition = rules.nextTransition(now.toInstant()); | |
Instant max = now.plusYears(15).toInstant(); | |
while (transition != null && transition.getInstant().isBefore(max)) { | |
System.out.println(transition); | |
transition = rules.nextTransition(transition.getInstant()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment