Created
April 27, 2019 21:28
-
-
Save juanpabloprado/b8d19627593b82e7df280b4a0c24dc71 to your computer and use it in GitHub Desktop.
DateTime Predefined Formatters 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> import static java.time.format.DateTimeFormatter.*; | |
jshell> ld.format(ISO_WEEK_DATE); | |
$43 ==> "2019-W17-6" | |
jshell> import java.time.OffsetDateTime; | |
jshell> OffsetDateTime odt = OffsetDateTime.now(); | |
odt ==> 2019-04-27T16:22:54.724099-05:00 | |
jshell> odt.format(ISO_DATE); | |
$46 ==> "2019-04-27-05:00" | |
jshell> odt.format(ISO_OFFSET_DATE); | |
$47 ==> "2019-04-27-05:00" | |
jshell> odt.format(ISO_OFFSET_DATE_TIME); | |
$48 ==> "2019-04-27T16:22:54.724099-05:00" | |
jshell> import java.time.ZonedDateTime; | |
jshell> ZonedDateTime zdt = ZonedDateTime.now(); | |
zdt ==> 2019-04-27T16:24:42.661513-05:00[America/Monterrey] | |
jshell> zdt.format(ISO_DATE_TIME); | |
$51 ==> "2019-04-27T16:24:42.661513-05:00[America/Monterrey]" | |
jshell> zdt.format(ISO_ZONED_DATE_TIME); | |
$52 ==> "2019-04-27T16:24:42.661513-05:00[America/Monterrey]" | |
jshell> zdt.format(RFC_1123_DATE_TIME); | |
$53 ==> "Sat, 27 Apr 2019 16:24:42 -0500" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment