Locale locale = Locale.JAPAN;
LocalDateTime now = LocalDateTime.now();
Programme de sortie
Formatez avec ofLocalizedDateTime.
System.out.println(
now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withLocale(locale))
);
System.out.println(
now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withLocale(locale))
);
System.out.println(
now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(locale))
);
System.out.println(
now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(locale))
);
Résultat d'exécution (à partir du haut, PLEIN, LONG, MOYEN, COURT)
java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
2019/07/01 7:59:30
2019/07/01 7:59
Résultat d'exécution (à partir du haut, PLEIN, LONG, MOYEN, COURT)
java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
Jul 1, 2019, 7:57:26 AM
7/1/19, 7:57 AM
Recommended Posts