Search in sources :

Example 6 with Chronology

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

the class TestChronoLocalDate method test_date_checkGenerics_chronoLocalDateTime2.

public void test_date_checkGenerics_chronoLocalDateTime2() {
    LocalDateTime now = LocalDateTime.now();
    Chronology chrono = ThaiBuddhistChronology.INSTANCE;
    ChronoLocalDateTime<? extends ChronoLocalDate> ldt = chrono.localDateTime(now);
    ldt = processCLDT(ldt);
}
Also used : ChronoLocalDateTime(java.time.chrono.ChronoLocalDateTime) LocalDateTime(java.time.LocalDateTime) Chronology(java.time.chrono.Chronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology)

Example 7 with Chronology

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

the class TestExampleCode method test_HijrahTypeViaLocale.

@Test(dataProvider = "HijrahTypeNames")
public void test_HijrahTypeViaLocale(String calendarId, String calendarType) {
    Locale.Builder builder = new Locale.Builder();
    builder.setLanguage("en").setRegion("US");
    builder.setUnicodeLocaleKeyword("ca", calendarType);
    Locale locale = builder.build();
    Chronology chrono = Chronology.ofLocale(locale);
    System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n", locale.toLanguageTag(), chrono, chrono.getCalendarType());
    Chronology expected = Chronology.of(calendarId);
    assertEquals(chrono, expected, "Expected chronology not found");
}
Also used : Locale(java.util.Locale) HijrahChronology(java.time.chrono.HijrahChronology) Chronology(java.time.chrono.Chronology) Test(org.testng.annotations.Test)

Example 8 with Chronology

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

the class TCKCopticSerialization method test_eraSerialization.

@Test
public void test_eraSerialization() throws IOException, ClassNotFoundException {
    Chronology chrono = Chronology.of("Coptic");
    ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
    assertSerializable(copticDate);
}
Also used : ChronoLocalDate(java.time.chrono.ChronoLocalDate) Chronology(java.time.chrono.Chronology) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 9 with Chronology

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

the class TCKThaiBuddhistChronology method test_chrono_byLocale_oldTH_noVariant.

@Test
public void test_chrono_byLocale_oldTH_noVariant() {
    // deliberately different to Calendar
    Chronology test = Chronology.ofLocale(new Locale("th", "TH"));
    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) Test(org.testng.annotations.Test)

Example 10 with Chronology

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

the class TCKThaiBuddhistChronology method test_chrono_byName.

//-----------------------------------------------------------------------
// Chronology.of(String)
//-----------------------------------------------------------------------
@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);
}
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)

Aggregations

Chronology (java.time.chrono.Chronology)114 IsoChronology (java.time.chrono.IsoChronology)95 Test (org.testng.annotations.Test)66 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)42 LocalDate (java.time.LocalDate)39 Test (org.junit.Test)32 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)27 TemporalAmount (java.time.temporal.TemporalAmount)12 TemporalUnit (java.time.temporal.TemporalUnit)12 TemporalAccessor (java.time.temporal.TemporalAccessor)10 TemporalField (java.time.temporal.TemporalField)9 ZoneId (java.time.ZoneId)8 Locale (java.util.Locale)8 DateTimeException (java.time.DateTimeException)6 TemporalAdjuster (java.time.temporal.TemporalAdjuster)6 ArrayList (java.util.ArrayList)6