Calendar
This commit is contained in:
67
src/org/eidecker/oca8lernen/general/CalendarAPI.java
Normal file
67
src/org/eidecker/oca8lernen/general/CalendarAPI.java
Normal 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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
13
src/org/eidecker/oca8lernen/general/ValidIdentifier.java
Normal file
13
src/org/eidecker/oca8lernen/general/ValidIdentifier.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package org.eidecker.oca8lernen.general;
|
||||
|
||||
public class ValidIdentifier {
|
||||
|
||||
class $ {
|
||||
|
||||
String H1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user