Search in sources :

Example 1 with ThaiBuddhistChronology

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

the class TCKThaiBuddhistChronology 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 ThaiBuddhistChronology) {
            continue;
        }
        List<Era> eras = chrono.eras();
        for (Era era : eras) {
            try {
                ChronoLocalDate date = ThaiBuddhistChronology.INSTANCE.date(era, 1, 1, 1);
                fail("ThaiBuddhistChronology.date did not throw ClassCastException for Era: " + era);
            } catch (ClassCastException cex) {
                // ignore expected exception
                ;
            }
            try {
                @SuppressWarnings("unused") int year = ThaiBuddhistChronology.INSTANCE.prolepticYear(era, 1);
                fail("ThaiBuddhistChronology.prolepticYear did not throw ClassCastException for Era: " + era);
            } catch (ClassCastException cex) {
                // ignore expected exception
                ;
            }
        }
    }
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) ThaiBuddhistEra(java.time.chrono.ThaiBuddhistEra) Era(java.time.chrono.Era) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology) IsoChronology(java.time.chrono.IsoChronology) Chronology(java.time.chrono.Chronology) MinguoChronology(java.time.chrono.MinguoChronology) Test(org.testng.annotations.Test)

Example 2 with ThaiBuddhistChronology

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

the class TestChronoLocalDate method test_date_checkGenerics_genericsMethod_concreteType.

public void test_date_checkGenerics_genericsMethod_concreteType() {
    ThaiBuddhistChronology chrono = ThaiBuddhistChronology.INSTANCE;
    ThaiBuddhistDate date = chrono.dateNow();
    date = ThaiBuddhistDate.now();
    date = processOK(date);
    date = processClassOK(ThaiBuddhistDate.class);
    date = dateSupplier();
// date = processClassWeird(ThaiBuddhistDate.class);  // does not compile (correct)
}
Also used : ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology)

Aggregations

ThaiBuddhistChronology (java.time.chrono.ThaiBuddhistChronology)2 ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 Chronology (java.time.chrono.Chronology)1 Era (java.time.chrono.Era)1 IsoChronology (java.time.chrono.IsoChronology)1 MinguoChronology (java.time.chrono.MinguoChronology)1 ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)1 ThaiBuddhistEra (java.time.chrono.ThaiBuddhistEra)1 Test (org.testng.annotations.Test)1