Search in sources :

Example 56 with Chronology

use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.

the class TCKChronology method test_MinguoChronology_dateNow.

//-----------------------------------------------------------------------
// dateNow()
//-----------------------------------------------------------------------
@Test
public void test_MinguoChronology_dateNow() {
    ZoneId zoneId_paris = ZoneId.of("Europe/Paris");
    Clock clock = Clock.system(zoneId_paris);
    Chronology chrono = Chronology.of("Minguo");
    assertEquals(chrono.dateNow(), MinguoChronology.INSTANCE.dateNow());
    assertEquals(chrono.dateNow(zoneId_paris), MinguoChronology.INSTANCE.dateNow(zoneId_paris));
    assertEquals(chrono.dateNow(clock), MinguoChronology.INSTANCE.dateNow(clock));
}
Also used : ZoneId(java.time.ZoneId) HijrahChronology(java.time.chrono.HijrahChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) JapaneseChronology(java.time.chrono.JapaneseChronology) Clock(java.time.Clock) Test(org.testng.annotations.Test)

Example 57 with Chronology

use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.

the class TCKChronology method test_MinguoChronology_dateYearDay.

@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));
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) HijrahChronology(java.time.chrono.HijrahChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) JapaneseChronology(java.time.chrono.JapaneseChronology) Test(org.testng.annotations.Test)

Example 58 with Chronology

use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.

the class TCKChronology method test_calendar_list.

@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);
}
Also used : HijrahChronology(java.time.chrono.HijrahChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) JapaneseChronology(java.time.chrono.JapaneseChronology) Test(org.testng.annotations.Test)

Example 59 with Chronology

use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.

the class TCKChronology method test_getters.

@Test(dataProvider = "calendarNameAndType")
public void test_getters(String chronoId, String calendarSystemType) {
    Chronology chrono = Chronology.of(chronoId);
    assertNotNull(chrono, "Required calendar not found by ID: " + chronoId);
    assertEquals(chrono.getId(), chronoId);
    assertEquals(chrono.getCalendarType(), calendarSystemType);
}
Also used : HijrahChronology(java.time.chrono.HijrahChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) JapaneseChronology(java.time.chrono.JapaneseChronology) Test(org.testng.annotations.Test)

Example 60 with Chronology

use of java.time.chrono.Chronology in project jdk8u_jdk by JetBrains.

the class TCKChronoLocalDateTime method test_badPlusAdjusterChrono.

@Test(dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chronology chrono) {
    LocalDate refDate = LocalDate.of(2013, 1, 1);
    ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
    for (Chronology[] clist : data_of_calendars()) {
        Chronology chrono2 = clist[0];
        ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
        TemporalAmount adjuster = new FixedAdjuster(cdt2);
        if (chrono != chrono2) {
            try {
                cdt.plus(adjuster);
                Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + cdt + ", supplied: " + cdt2);
            } catch (ClassCastException cce) {
            // Expected exception; not an error
            }
        } else {
            // Same chronology,
            ChronoLocalDateTime<?> result = cdt.plus(adjuster);
            assertEquals(result, cdt2, "WithAdjuster failed to replace date time");
        }
    }
}
Also used : TemporalAmount(java.time.temporal.TemporalAmount) HijrahChronology(java.time.chrono.HijrahChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) JapaneseChronology(java.time.chrono.JapaneseChronology) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Aggregations

Chronology (java.time.chrono.Chronology)76 Test (org.testng.annotations.Test)65 IsoChronology (java.time.chrono.IsoChronology)59 ThaiBuddhistChronology (java.time.chrono.ThaiBuddhistChronology)58 MinguoChronology (java.time.chrono.MinguoChronology)54 HijrahChronology (java.time.chrono.HijrahChronology)47 JapaneseChronology (java.time.chrono.JapaneseChronology)46 ChronoLocalDate (java.time.chrono.ChronoLocalDate)29 LocalDate (java.time.LocalDate)21 Locale (java.util.Locale)7 TemporalAmount (java.time.temporal.TemporalAmount)6 TemporalUnit (java.time.temporal.TemporalUnit)6 ZoneId (java.time.ZoneId)5 TemporalAccessor (java.time.temporal.TemporalAccessor)5 Clock (java.time.Clock)4 DateTimeException (java.time.DateTimeException)4 Era (java.time.chrono.Era)4 TemporalField (java.time.temporal.TemporalField)4 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)3 DateTimeFormatter (java.time.format.DateTimeFormatter)3