Last active
August 12, 2019 08:52
-
-
Save will-molloy/ecd1d31d7d7a0835b5fda21d3e57c374 to your computer and use it in GitHub Desktop.
Java time API (JSR 310) is smarter than initially thought
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
public static void main(String[] args) { | |
ZonedDateTime auckland = ZonedDateTime.of(LocalDateTime.of(2019, Month.AUGUST, 12, 20, 45), ZoneId.of("Pacific/Auckland")); | |
ZonedDateTime london = ZonedDateTime.of(LocalDateTime.of(2019, Month.AUGUST, 12, 9, 45), ZoneId.of("Europe/London")); | |
System.out.println(auckland.equals(london)); // false | |
System.out.println(auckland.isEqual(london)); // true | |
auckland = ZonedDateTime.of(LocalDateTime.of(2019, Month.DECEMBER, 12, 20, 45), ZoneId.of("Pacific/Auckland")); | |
london = ZonedDateTime.of(LocalDateTime.of(2019, Month.DECEMBER, 12, 7, 45), ZoneId.of("Europe/London")); | |
System.out.println(auckland.equals(london)); // false | |
System.out.println(auckland.isEqual(london)); // true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment