Last active
April 27, 2019 22:04
-
-
Save juanpabloprado/402d76586335505100b958fcccb56a9a to your computer and use it in GitHub Desktop.
Localized formatting for LocalDate 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> // Localized formatting for LocalDate | |
jshell> import java.time.LocalDate; | |
jshell> LocalDate ld = LocalDate.now(); | |
ld ==> 2019-04-27 | |
jshell> import java.time.format.FormatStyle; | |
jshell> "SHORT: " + ld.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)); | |
$71 ==> "SHORT: 4/27/19" | |
jshell> "MEDIUM: " + ld.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)); | |
$72 ==> "MEDIUM: Apr 27, 2019" | |
jshell> "LONG: " + ld.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG)); | |
$73 ==> "LONG: April 27, 2019" | |
jshell> "FULL: " + ld.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)); | |
$74 ==> "FULL: Saturday, April 27, 2019" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment