List of usage examples for java.time.zone ZoneOffsetTransition getInstant
public Instant getInstant()
From source file:org.nodatime.tzvalidate.Java8Dump.java
@Override public ZoneTransitions getTransitions(String id, int fromYear, int toYear) { ZoneId zone = ZoneId.of(id); ZoneRules rules = zone.getRules(); DateTimeFormatter nameFormat = DateTimeFormatter.ofPattern("zzz", Locale.US); ZoneTransitions transitions = new ZoneTransitions(id); Instant start = ZonedDateTime.of(fromYear, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).toInstant(); transitions.addTransition(null, rules.getOffset(start).getTotalSeconds() * 1000, rules.isDaylightSavings(start), nameFormat.format(start.atZone(zone))); Instant end = ZonedDateTime.of(toYear, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).toInstant(); ZoneOffsetTransition transition = rules.nextTransition(start.minusNanos(1)); while (transition != null && transition.getInstant().isBefore(end)) { Instant instant = transition.getInstant(); transitions.addTransition(new Date(instant.toEpochMilli()), rules.getOffset(instant).getTotalSeconds() * 1000, rules.isDaylightSavings(instant), nameFormat.format(instant.atZone(zone))); transition = rules.nextTransition(instant); }//from w w w.j av a 2s . c om return transitions; }