September 2019
Intermediate to advanced
816 pages
18h 47m
English
In order to convert from Date to Instant, the solution can rely on the Date.toInstant() method. The reverse can be accomplished via the Date.from(Instant instant) method:
Date date = new Date();// e.g., 2019-02-27T12:02:49.369Z, UTCInstant instantFromDate = date.toInstant();
Instant instant = Instant.now();// Wed Feb 27 14:02:49 EET 2019, default system time zoneDate dateFromInstant = Date.from(instant);
Let's quickly wrap these snippets of code in two utility methods, ...