Created
April 24, 2019 03:14
-
-
Save juanpabloprado/6f192e2f293fbc752674dcec076943e1 to your computer and use it in GitHub Desktop.
LocalDate and LocalTime plus/minus methods on the Java Shell tool
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
jshell> LocalDate ld = LocalDate.now(); | |
ld ==> 2019-04-23 | |
jshell> // All plus methods | |
jshell> ld = ld.plusYears(1).plusMonths(12).plusWeeks(52).plusDays(365); | |
ld ==> 2023-04-22 | |
jshell> // All minus methods | |
jshell> ld = ld.minusYears(1).minusMonths(12).minusWeeks(52).minusDays(365); | |
ld ==> 2019-04-24 | |
jshell> LocalTime lt = LocalTime.now(); | |
lt ==> 22:09:45.241958 | |
jshell> // All plus methods | |
jshell> lt = lt.plusHours(18765).plusMinutes(525949).plusSeconds(0).plusNanos(0); | |
lt ==> 00:58:45.241958 | |
jshell> lt = lt.minusHours(1).minusMinutes(1).minusSeconds(1).minusNanos(1); | |
lt ==> 23:57:44.241957999 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment