Java Code Examples for java.time.chrono.Chronology#of()

The following examples show how to use java.time.chrono.Chronology#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKThaiBuddhistChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_chrono_byName() {
    Chronology c = ThaiBuddhistChronology.INSTANCE;
    Chronology test = Chronology.of("ThaiBuddhist");
    Assert.assertNotNull(test, "The ThaiBuddhist calendar could not be found byName");
    Assert.assertEquals(test.getId(), "ThaiBuddhist", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "buddhist", "Type mismatch");
    Assert.assertEquals(test, c);
}
 
Example 2
Source File: TCKChronology.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_HijrahChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Hijrah");
    ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178);
    ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1);
    assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
    assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
}
 
Example 3
Source File: TCKMinguoChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_chrono_byName() {
    Chronology c = MinguoChronology.INSTANCE;
    Chronology test = Chronology.of("Minguo");
    Assert.assertNotNull(test, "The Minguo calendar could not be found byName");
    Assert.assertEquals(test.getId(), "Minguo", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch");
    Assert.assertEquals(test, c);
}
 
Example 4
Source File: TCKChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_JapaneseChronology_dateNow() {
    ZoneId zoneId_paris = ZoneId.of("Europe/Paris");
    Clock clock = Clock.system(zoneId_paris);

    Chronology chrono = Chronology.of("Japanese");
    assertEquals(chrono.dateNow(), JapaneseChronology.INSTANCE.dateNow());
    assertEquals(chrono.dateNow(zoneId_paris), JapaneseChronology.INSTANCE.dateNow(zoneId_paris));
    assertEquals(chrono.dateNow(clock), JapaneseChronology.INSTANCE.dateNow(clock));
}
 
Example 5
Source File: TCKMinguoChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_chrono_byName() {
    Chronology c = MinguoChronology.INSTANCE;
    Chronology test = Chronology.of("Minguo");
    Assert.assertNotNull(test, "The Minguo calendar could not be found byName");
    Assert.assertEquals(test.getId(), "Minguo", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch");
    Assert.assertEquals(test, c);
}
 
Example 6
Source File: TCKChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_calendar_list() {
    Set<Chronology> chronos = Chronology.getAvailableChronologies();
    assertNotNull(chronos, "Required list of calendars must be non-null");
    for (Chronology chrono : chronos) {
        Chronology lookup = Chronology.of(chrono.getId());
        assertNotNull(lookup, "Required calendar not found: " + chrono);
    }
    assertEquals(chronos.size() >= data_of_calendars().length, true, "Chronology.getAvailableChronologies().size = " + chronos.size()
            + ", expected >= " + data_of_calendars().length);
}
 
Example 7
Source File: TCKChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_ThaiBuddhistChronology_dateNow() {
    ZoneId zoneId_paris = ZoneId.of("Europe/Paris");
    Clock clock = Clock.system(zoneId_paris);

    Chronology chrono = Chronology.of("ThaiBuddhist");
    assertEquals(chrono.dateNow(), ThaiBuddhistChronology.INSTANCE.dateNow());
    assertEquals(chrono.dateNow(zoneId_paris), ThaiBuddhistChronology.INSTANCE.dateNow(zoneId_paris));
    assertEquals(chrono.dateNow(clock), ThaiBuddhistChronology.INSTANCE.dateNow(clock));
}
 
Example 8
Source File: TCKChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "calendarNameAndType")
public void test_dateEpochDay(String name, String alias) {
    Chronology chrono = Chronology.of(name);
    ChronoLocalDate date = chrono.dateNow();
    long epochDay = date.getLong(ChronoField.EPOCH_DAY);
    ChronoLocalDate test = chrono.dateEpochDay(epochDay);
    assertEquals(test, date);
}
 
Example 9
Source File: TCKChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_MinguoChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Minguo");
    ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60);
    ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29);
    assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
    assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
}
 
Example 10
Source File: TCKHijrahChronology.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_chrono_byName() {
    Chronology c = HijrahChronology.INSTANCE;
    Chronology test = Chronology.of("Hijrah-umalqura");
    Assert.assertNotNull(test, "The Hijrah-umalqura calendar could not be found by name");
    Assert.assertEquals(test.getId(), "Hijrah-umalqura", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "islamic-umalqura", "Type mismatch");
    Assert.assertEquals(test, c);
}
 
Example 11
Source File: TestIsoChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_chrono_byName() {
    Chronology c = IsoChronology.INSTANCE;
    Chronology test = Chronology.of("ISO");
    Assert.assertNotNull(test, "The ISO calendar could not be found byName");
    Assert.assertEquals(test.getId(), "ISO", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "iso8601", "Type mismatch");
    Assert.assertEquals(test, c);
}
 
Example 12
Source File: TCKChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_MinguoChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Minguo");
    ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60);
    ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29);
    assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
    assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
}
 
Example 13
Source File: TCKChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_JapaneseChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Japanese");
    ChronoLocalDate date1 = chrono.dateYearDay(JapaneseEra.HEISEI, 8, 60);
    ChronoLocalDate date2 = chrono.date(JapaneseEra.HEISEI, 8, 2, 29);
    assertEquals(date1, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
    assertEquals(date2, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
}
 
Example 14
Source File: TCKChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_ThaiBuddhistChronology_dateYearDay() {
    Chronology chrono = Chronology.of("ThaiBuddhist");
    ChronoLocalDate date1 = chrono.dateYearDay(ThaiBuddhistEra.BE, 2459, 60);
    ChronoLocalDate date2 = chrono.date(ThaiBuddhistEra.BE, 2459, 2, 29);
    assertEquals(date1, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60));
    assertEquals(date2, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60));
}
 
Example 15
Source File: TCKChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_MinguoChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Minguo");
    ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60);
    ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29);
    assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
    assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60));
}
 
Example 16
Source File: TCKHijrahChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_chrono_byName() {
    Chronology c = HijrahChronology.INSTANCE;
    Chronology test = Chronology.of("Hijrah-umalqura");
    Assert.assertNotNull(test, "The Hijrah-umalqura calendar could not be found by name");
    Assert.assertEquals(test.getId(), "Hijrah-umalqura", "ID mismatch");
    Assert.assertEquals(test.getCalendarType(), "islamic-umalqura", "Type mismatch");
    Assert.assertEquals(test, c);
}
 
Example 17
Source File: TCKChronology.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_HijrahChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Hijrah");
    ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178);
    ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1);
    assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
    assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
}
 
Example 18
Source File: TCKTestServiceLoader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
 public void test_TestServiceLoader() {
    Chronology chrono = Chronology.of("Coptic");
    ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
    LocalDate ld = LocalDate.from(copticDate);
    assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate");
}
 
Example 19
Source File: TCKChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "calendarDisplayName")
public void test_getDisplayName(String chronoId, String calendarDisplayName) {
    Chronology chrono = Chronology.of(chronoId);
    assertEquals(chrono.getDisplayName(TextStyle.FULL, Locale.ENGLISH), calendarDisplayName);
}
 
Example 20
Source File: TCKCopticSerialization.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void test_eraSerialization() throws IOException, ClassNotFoundException {
    Chronology chrono = Chronology.of("Coptic");
    ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
    assertSerializable(copticDate);
}