September 2019
Intermediate to advanced
816 pages
18h 47m
English
For adding time, Instant has a suite of methods. For example, adding 2 hours to the current timestamp can be accomplished as follows:
Instant twoHourLater = Instant.now().plus(2, ChronoUnit.HOURS);
In terms of subtracting time, for example, 10 minutes, use the following code snippet:
Instant tenMinutesEarlier = Instant.now() .minus(10, ChronoUnit.MINUTES);