@@ -1,6 +1,17 @@
|
||||
## Deklaration
|
||||
Drei verschiedene Klassen für Datum, Zeit und Datum mit Zeit.
|
||||
|
||||
```
|
||||
LocalDate date = LocalDate.of(2020, Month.APRIL, 14);
|
||||
LocalTime time = LocalTime.of(12, 45);
|
||||
LocalDateTime dateTime = LocalDateTime.of(date, time);
|
||||
```
|
||||
|
||||
## Wichtige Eigenschaften
|
||||
- **Immutable**: Keine direkten Änderungen möglich, es werden immer neue Objekte zurückgegeben
|
||||
- **Factory-Methoden, private Konstruktoren**: `LocalDate`, `LocalTime` und `LocalDateTime` müssen über Factory-Methoden erzeugt werden, haben private Konstruktoren.
|
||||
|
||||
## Formatierte Ausgabe
|
||||
- Formatierung per `DateTimeFormatter`
|
||||
- Erzeugung per Factory (`DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user