Datumsformatierung & Übersetzung per DateTimeFormatter
This commit is contained in:
parent
f56b5f4d7e
commit
c019de645d
|
|
@ -27,12 +27,8 @@ public class Geburtstag {
|
|||
myBirthday = setMyBirthday();
|
||||
if (myBirthday != null) {
|
||||
System.out.println("Mein Geburtsdatum mit Geburtszeit ist:");
|
||||
System.out.println(translateDate(myBirthday.getDayOfWeek().toString()) + ", der " +
|
||||
myBirthday.getDayOfMonth() + ". " +
|
||||
translateDate(myBirthday.getMonth().toString()) + " " +
|
||||
myBirthday.getYear() + ", " +
|
||||
myBirthday.getHour() + ":" +
|
||||
myBirthday.getMinute() + " Uhr");
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EEEE, 'der' dd. MMMM yyyy, HH:mm 'Uhr'");
|
||||
System.out.println(myBirthday.format(dtf));
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +79,6 @@ public class Geburtstag {
|
|||
public static LocalDateTime setMyBirthday() {
|
||||
|
||||
Scanner myInput = new Scanner(System.in);
|
||||
LocalDateTime tempDateTime = null;
|
||||
|
||||
/* Aufgabe b)
|
||||
|
||||
|
|
@ -168,35 +163,6 @@ public class Geburtstag {
|
|||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String translateDate(String wort) {
|
||||
|
||||
HashMap<String, String> dictionary = new HashMap<>();
|
||||
dictionary.put("monday", "Montag");
|
||||
dictionary.put("tuesday", "Dienstag");
|
||||
dictionary.put("wednesday", "Mittwoch");
|
||||
dictionary.put("thursday", "Donnerstag");
|
||||
dictionary.put("friday", "Freitag");
|
||||
dictionary.put("saturday", "Samstag");
|
||||
dictionary.put("sunday", "Sonntag");
|
||||
dictionary.put("january", "Januar");
|
||||
dictionary.put("february", "Februar");
|
||||
dictionary.put("march", "März");
|
||||
dictionary.put("april", "April");
|
||||
dictionary.put("may", "Mai");
|
||||
dictionary.put("june", "Juni");
|
||||
dictionary.put("july", "Juli");
|
||||
dictionary.put("august", "August");
|
||||
dictionary.put("september", "September");
|
||||
dictionary.put("october", "Oktober");
|
||||
dictionary.put("november", "November");
|
||||
dictionary.put("december", "Dezember");
|
||||
|
||||
return dictionary.get(wort.toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue