This commit is contained in:
Sebastian Eidecker
2019-11-10 17:32:59 +01:00
parent af20aae8b1
commit 71aaab2940
3 changed files with 87 additions and 2 deletions

View File

@@ -0,0 +1,67 @@
package org.eidecker.oca8lernen.general;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.UnsupportedTemporalTypeException;
import org.junit.jupiter.api.Test;
public class CalendarAPI {
@Test
public void testCalendarAPI() {
LocalDate date = LocalDate.of(2020, Month.APRIL, 3);
LocalTime time = LocalTime.of(12, 45);
LocalDateTime dateTime = LocalDateTime.of(date, time);
DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
DateTimeFormatter timeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
System.out.println(dateFormatter.format(date));
System.out.println(timeFormatter.format(time));
System.out.println(dateTimeFormatter.format(dateTime));
DateTimeFormatter myOwnFormatter = DateTimeFormatter.ofPattern("MM d yyyy, HH:mm");
System.out.println(myOwnFormatter.format(dateTime));
assertThrows(UnsupportedTemporalTypeException.class, () -> {
dateTimeFormatter.format(time);
});
assertThrows(UnsupportedTemporalTypeException.class, () -> {
myOwnFormatter.format(time);
});
}
@Test
public void parseDates() {
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyMMddHHmm");
LocalTime localTime = LocalTime.parse("23:11", timeFormatter);
localTime = LocalTime.parse("1901221209", dateTimeFormatter);
LocalDateTime dateTime;
dateTime = LocalDateTime.parse("1908221132", dateTimeFormatter);
}
@Test
public void testTheImpossible() {
// LocalDate date = new LocalDate();
}
}

View File

@@ -27,11 +27,16 @@ public class KLassenInitialisierung {
class Oberklasse {
static {
System.out.println("Oberklasse statischer Initialisierungsblock");
synchronized (Oberklasse.class) {
System.out.println("Oberklasse statischer Initialisierungsblock");
}
}
{
System.out.println("Oberklasse Initialisierungsblock");
synchronized (this) {
System.out.println("Oberklasse Initialisierungsblock");
}
}

View File

@@ -0,0 +1,13 @@
package org.eidecker.oca8lernen.general;
public class ValidIdentifier {
class $ {
String H1;
}
}