Created
April 27, 2019 21:02
-
-
Save juanpabloprado/385604170089ae96c10eae247de14ab3 to your computer and use it in GitHub Desktop.
Period between method 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
shell> String WAR_OF_1812_START_DATE = "1812-06-18"; | |
WAR_OF_1812_START_DATE ==> "1812-06-18" | |
jshell> String WAR_OF_1812_END_DATE = "1815-02-18"; | |
WAR_OF_1812_END_DATE ==> "1815-02-18" | |
jshell> import java.time.LocalDate; | |
jshell> LocalDate warBegins = LocalDate.parse(WAR_OF_1812_START_DATE); | |
warBegins ==> 1812-06-18 | |
jshell> LocalDate warEnds = LocalDate.parse(WAR_OF_1812_END_DATE); | |
warEnds ==> 1815-02-18 | |
jshell> Period period = Period.between(warBegins, warEnds); | |
period ==> P2Y8M | |
jshell> "WAR OF 1812 TIMEFRAME: " + period; | |
$34 ==> "WAR OF 1812 TIMEFRAME: P2Y8M" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment