Skip to content

Instantly share code, notes, and snippets.

@AndrewReitz
Created April 10, 2016 12:11
Show Gist options
  • Save AndrewReitz/fb104cbe6a87bf898036e8f5c4c17bba to your computer and use it in GitHub Desktop.
Save AndrewReitz/fb104cbe6a87bf898036e8f5c4c17bba to your computer and use it in GitHub Desktop.
Java 8 Dates
// 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