Skip to content

Instantly share code, notes, and snippets.

@relax-more
Created December 3, 2015 08:02
Show Gist options
  • Save relax-more/85ac709ef8827c938d17 to your computer and use it in GitHub Desktop.
Save relax-more/85ac709ef8827c938d17 to your computer and use it in GitHub Desktop.
java Date --> Instant

java.time.Instant

Instant (java.time.Instant) Probably the best place to start with the java.time package is the Instant class. An Instant represents a point in time (similar to java.util.Date) with nanoseconds precision (unlike the old Date which has milliseconds precision). Representing a point in time using nanoseconds precision requires more space than a Long can provide, therefore the internal representation is composed of two Long fields, the first holds the number of seconds since (or before) the standard Java epoch and the other the number of nanoseconds of the last seconds (so never larger than 999,999,999). Let's start with obtaining an Instant instance and print its value:

refed by https://dzone.com/articles/java-8-apis-javautiltime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment