Created
April 24, 2019 02:47
-
-
Save juanpabloprado/73245e928dca8262036d4bfa1b4c55a6 to your computer and use it in GitHub Desktop.
LocalDateTime Class 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> LocalDateTime ldt1 = LocalDateTime.now(); | |
ldt1 ==> 2019-04-23T21:41:59.084165 | |
jshell> LocalDateTime ldt2 = LocalDateTime.parse("2019-01-01T12:00:00"); | |
ldt2 ==> 2019-01-01T12:00 | |
jshell> LocalDateTime ldt3 = LocalDateTime.of(2019, 1, 1, 12, 0); | |
ldt3 ==> 2019-01-01T12:00 | |
jshell> LocalDateTime ldt4 = LocalDateTime.of(2019, Month.JANUARY, 1, 12, 0); | |
ldt4 ==> 2019-01-01T12:00 | |
jshell> LocalDateTime ldt5 = LocalDateTime.of(2019, 1, 1, 12, 0, 1); | |
ldt5 ==> 2019-01-01T12:00:01 | |
jshell> LocalDateTime ldt6 = LocalDateTime.now(ZoneId.of("Asia/Tokyo")); | |
ldt6 ==> 2019-04-24T11:45:14.493228 | |
jshell> LocalDateTime ldt7 = LocalDateTime.parse("2019-01-01 12:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); | |
ldt7 ==> 2019-01-01T12:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment