Search in sources :

Example 1 with JapaneseChronology

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

the class TCKJapaneseChronology method test_InvalidEras.

//-----------------------------------------------------------------------
// Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...)
//-----------------------------------------------------------------------
@Test
public void test_InvalidEras() {
    // Verify that the eras from every other Chronology are invalid
    for (Chronology chrono : Chronology.getAvailableChronologies()) {
        if (chrono instanceof JapaneseChronology) {
            continue;
        }
        List<Era> eras = chrono.eras();
        for (Era era : eras) {
            try {
                ChronoLocalDate date = JapaneseChronology.INSTANCE.date(era, 1, 1, 1);
                fail("JapaneseChronology.date did not throw ClassCastException for Era: " + era);
            } catch (ClassCastException cex) {
                // ignore expected exception
                ;
            }
            try {
                @SuppressWarnings("unused") int year = JapaneseChronology.INSTANCE.prolepticYear(era, 1);
                fail("JapaneseChronology.prolepticYear did not throw ClassCastException for Era: " + era);
            } catch (ClassCastException cex) {
                // ignore expected exception
                ;
            }
        }
    }
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) JapaneseEra(java.time.chrono.JapaneseEra) Era(java.time.chrono.Era) 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) JapaneseChronology(java.time.chrono.JapaneseChronology) Test(org.testng.annotations.Test)

Aggregations

ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 Chronology (java.time.chrono.Chronology)1 Era (java.time.chrono.Era)1 IsoChronology (java.time.chrono.IsoChronology)1 JapaneseChronology (java.time.chrono.JapaneseChronology)1 JapaneseEra (java.time.chrono.JapaneseEra)1 MinguoChronology (java.time.chrono.MinguoChronology)1 ThaiBuddhistChronology (java.time.chrono.ThaiBuddhistChronology)1 Test (org.testng.annotations.Test)1