Skip to content

Instantly share code, notes, and snippets.

@juanpabloprado
Last active April 27, 2019 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloprado/402d76586335505100b958fcccb56a9a to your computer and use it in GitHub Desktop.
Save juanpabloprado/402d76586335505100b958fcccb56a9a to your computer and use it in GitHub Desktop.
Localized formatting for LocalDate on the Java Shell tool
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