use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_chrono_byName.
//-----------------------------------------------------------------------
// Chronology.of(String)
//-----------------------------------------------------------------------
@Test
public void test_chrono_byName() {
Chronology c = JapaneseChronology.INSTANCE;
Chronology test = Chronology.of("Japanese");
Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
Assert.assertEquals(test, c);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TestExampleCode method test_calendarPackageExample.
@Test
public void test_calendarPackageExample() {
// Enumerate the list of available calendars and print today for each
Set<Chronology> chronos = Chronology.getAvailableChronologies();
for (Chronology chrono : chronos) {
ChronoLocalDate date = chrono.dateNow();
System.out.printf(" %20s: %s%n", chrono.getId(), date.toString());
}
// Print the Thai Buddhist date
ThaiBuddhistDate now1 = ThaiBuddhistDate.now();
int day = now1.get(ChronoField.DAY_OF_MONTH);
int dow = now1.get(ChronoField.DAY_OF_WEEK);
int month = now1.get(ChronoField.MONTH_OF_YEAR);
int year = now1.get(ChronoField.YEAR);
System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(), dow, day, month, year);
// Print today's date and the last day of the year for the Thai Buddhist Calendar.
ThaiBuddhistDate first = now1.with(ChronoField.DAY_OF_MONTH, 1).with(ChronoField.MONTH_OF_YEAR, 1);
ThaiBuddhistDate last = first.plus(1, ChronoUnit.YEARS).minus(1, ChronoUnit.DAYS);
System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(), first, last);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TestChronoLocalDate method test_date_checkGenerics_genericsMethod_withType.
public <D extends ChronoLocalDate> void test_date_checkGenerics_genericsMethod_withType() {
Chronology chrono = ThaiBuddhistChronology.INSTANCE;
@SuppressWarnings("unchecked") D date = (D) chrono.dateNow();
date = processOK(date);
// date = processClassOK(ThaiBuddhistDate.class); // does not compile (correct)
date = dateSupplier();
// date = processWeird(date); // does not compile (correct)
// date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct)
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TestChronoLocalDate method test_date_checkGenerics_chronoLocalDateTime1.
public void test_date_checkGenerics_chronoLocalDateTime1() {
LocalDateTime now = LocalDateTime.now();
Chronology chrono = ThaiBuddhistChronology.INSTANCE;
ChronoLocalDateTime<?> ldt = chrono.localDateTime(now);
ldt = processCLDT(ldt);
}
use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.
the class TestServiceLoader method test_copticServiceLoader.
@Test
public void test_copticServiceLoader() {
Map<String, Chronology> chronos = new HashMap<>();
ServiceLoader<Chronology> loader = ServiceLoader.load(Chronology.class, null);
for (Chronology chrono : loader) {
chronos.put(chrono.getId(), chrono);
}
assertNotNull(chronos.get("Coptic"), "CopticChronology not found");
}
Aggregations