Gibt es ein Muster zum Formatieren und Analysieren von Zeiträumen an einem Tag, z. B. „morgens“, „nachmittags“ oder „nac
Posted: 23 Dec 2024, 12:10
Ich möchte Zeiträume am Tag ausdrücken, beispielsweise morgens, nachmittags oder nachts, nicht nur AM oder PM.
Gibt es in der java.time-API ein Muster zum Formatieren und Analysieren von Zeiträumen an einem Tag, z. B. morgens, nachmittags oder nachts mit DateTimeFormatter z.B.
final DateTimeFormatter FORMATTER = DateTimeFormatter
.ofPattern("", Locale.ENGLISH);
// Expected output: in the morning
System.out.println(LocalTime.of(8, 20, 30).format(FORMATTER));
// Expected output: in the evening
System.out.println(LocalTime.of(20, 20, 30).format(FORMATTER));
Gibt es in der java.time-API ein Muster zum Formatieren und Analysieren von Zeiträumen an einem Tag, z. B. morgens, nachmittags oder nachts mit DateTimeFormatter z.B.
final DateTimeFormatter FORMATTER = DateTimeFormatter
.ofPattern("", Locale.ENGLISH);
// Expected output: in the morning
System.out.println(LocalTime.of(8, 20, 30).format(FORMATTER));
// Expected output: in the evening
System.out.println(LocalTime.of(20, 20, 30).format(FORMATTER));