Last active
April 27, 2019 21:39
-
-
Save juanpabloprado/01924ca15f487a3100a26b99c021a122 to your computer and use it in GitHub Desktop.
LocalDateTime 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 java.util.ArrayList; | |
jshell> import java.time.format.DateTimeFormatter; ^ | |
jshell> ArrayList<DateTimeFormatter> ldtFormattersList = new ArrayList<>(); | |
ldtFormattersList ==> [] | |
jshell> ldtFormattersList.add(DateTimeFormatter.BASIC_ISO_DATE); | |
$57 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_LOCAL_DATE); | |
$58 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_LOCAL_TIME); | |
$59 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_LOCAL_DATE_TIME); | |
$60 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_TIME); | |
$61 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_DATE); | |
$62 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_DATE_TIME); | |
$63 ==> true | |
jshell> ldtFormattersList.add(DateTimeFormatter.ISO_ORDINAL_DATE); | |
$64 ==> true | |
jshell> import java.time.LocalDateTime; | |
jshell> LocalDateTime ldt = LocalDateTime.now(); | |
ldt ==> 2019-04-27T16:35:55.066751 | |
jshell> ldtFormattersList.forEach(f -> { | |
...> System.out.println(ldt.format(f)); | |
...> }); | |
20190427 | |
2019-04-27 | |
16:35:55.066751 | |
2019-04-27T16:35:55.066751 | |
16:35:55.066751 | |
2019-04-27 | |
2019-04-27T16:35:55.066751 | |
2019-117 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment