From eeb1a8e5f19687db50eff01231af21ca91d6dc50 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Mon, 20 Apr 2020 15:00:18 +0200 Subject: [PATCH] nutze DateTimeFormatter --- src/geburtstag/Geburtstag.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/geburtstag/Geburtstag.java b/src/geburtstag/Geburtstag.java index 6a2e195..4e9ccb5 100644 --- a/src/geburtstag/Geburtstag.java +++ b/src/geburtstag/Geburtstag.java @@ -9,6 +9,8 @@ hier bitte die notwendigen imports ergänzen! import java.sql.SQLOutput; import java.time.DateTimeException; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; @@ -44,8 +46,7 @@ public class Geburtstag { jetzt = LocalDateTime.now(); System.out.println("Jetzt ist:"); - System.out.println(jetzt.getDayOfMonth() + "." + jetzt.getMonthValue() + "." + jetzt.getYear() + - ", " + jetzt.getHour() + ":" + jetzt.getMinute()); + System.out.println(jetzt.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM))); System.out.println(); int tageBisGeburtstag = 0;