Last active
April 27, 2019 22:05
-
-
Save juanpabloprado/17f643a78ed3f7121b2b837de28b063d to your computer and use it in GitHub Desktop.
Localized formatting for LocalDateTime 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> // Passing Formatters to LocalDateTime format method | |
jshell> LocalDateTime ldt = LocalDateTime.now(); | |
ldt ==> 2019-04-27T16:53:28.272418 | |
jshell> ldt.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)); | |
$82 ==> "4/27/19, 4:53 PM" | |
jshell> ldt.format(DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)); | |
$83 ==> "4:53 PM" | |
jshell> ldt.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)); | |
$84 ==> "4/27/19" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment