Search in sources :

Example 66 with Chronology

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

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

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

the class TCKMinguoChronology method test_chrono_byName.

//-----------------------------------------------------------------------
// Chronology.ofName("Minguo")  Lookup by name
//-----------------------------------------------------------------------
@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);
}
Also used : 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 68 with Chronology

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

the class TCKJapaneseChronology method test_chrono_byLocale_oldJP_noVariant.

@Test
public void test_chrono_byLocale_oldJP_noVariant() {
    Chronology test = Chronology.ofLocale(new Locale("ja", "JP"));
    Assert.assertEquals(test.getId(), "ISO");
    Assert.assertEquals(test, IsoChronology.INSTANCE);
}
Also used : Locale(java.util.Locale) 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 69 with Chronology

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

the class TCKJapaneseChronology method test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere.

@Test
public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() {
    Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese"));
    Assert.assertEquals(test.getId(), "Japanese");
    Assert.assertEquals(test, JapaneseChronology.INSTANCE);
}
Also used : 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 70 with Chronology

use of java.time.chrono.Chronology 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

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