Skip to content

Instantly share code, notes, and snippets.

@hishidama
Created June 30, 2015 14:16
Show Gist options
  • Save hishidama/6a2bf263608d09502d7b to your computer and use it in GitHub Desktop.
Save hishidama/6a2bf263608d09502d7b to your computer and use it in GitHub Desktop.
うるう秒が表示されるかどうか見てみる
package example.time;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class LeapSecondPrint {
public static void main(String... args) {
ZonedDateTime end = ZonedDateTime.of(2015, 7, 1, 0, 0, 2, 0, ZoneId.systemDefault());
for (ZonedDateTime now = ZonedDateTime.now(), prev = null; now.compareTo(end) <= 0; prev = now, now = ZonedDateTime.now()) {
if (!now.equals(prev)) {
System.out.println(now);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment