Created
April 10, 2016 12:11
-
-
Save AndrewReitz/fb104cbe6a87bf898036e8f5c4c17bba to your computer and use it in GitHub Desktop.
Java 8 Dates
This file contains 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
// Does what you expect | |
println ZonedDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()).minusYears(10).toInstant() | |
// throws an exception java.time.DateTimeException: Unable to obtain ChronoZonedDateTime from TemporalAccessor: class java.time.Instant | |
println ZonedDateTime.from(Instant.now()).minusYears(10).toInstant() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment