Search in sources :

Example 81 with Chronology

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

the class TCKChronology method test_dateEpochDay.

@Test(dataProvider = "calendarNameAndType")
public void test_dateEpochDay(String name, String alias) {
    Chronology chrono = Chronology.of(name);
    ChronoLocalDate date = chrono.dateNow();
    long epochDay = date.getLong(ChronoField.EPOCH_DAY);
    ChronoLocalDate test = chrono.dateEpochDay(epochDay);
    assertEquals(test, date);
}
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 82 with Chronology

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

the class TCKChronology method test_HijrahChronology_dateYearDay.

//-----------------------------------------------------------------------
// dateYearDay() and date()
//-----------------------------------------------------------------------
@Test
public void test_HijrahChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Hijrah");
    ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178);
    ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1);
    assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
    assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178));
}
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 83 with Chronology

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

the class TCKChronology method test_getDisplayName.

@Test(dataProvider = "calendarDisplayName")
public void test_getDisplayName(String chronoId, String calendarDisplayName) {
    Chronology chrono = Chronology.of(chronoId);
    assertEquals(chrono.getDisplayName(TextStyle.FULL, Locale.ENGLISH), calendarDisplayName);
}
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 84 with Chronology

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

the class TCKChronology method test_JapaneseChronology_dateYearDay.

@Test
public void test_JapaneseChronology_dateYearDay() {
    Chronology chrono = Chronology.of("Japanese");
    ChronoLocalDate date1 = chrono.dateYearDay(JapaneseEra.HEISEI, 8, 60);
    ChronoLocalDate date2 = chrono.date(JapaneseEra.HEISEI, 8, 2, 29);
    assertEquals(date1, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60));
    assertEquals(date2, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 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 85 with Chronology

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

the class TCKChronology method test_ThaiBuddhistChronology_dateNow.

@Test
public void test_ThaiBuddhistChronology_dateNow() {
    ZoneId zoneId_paris = ZoneId.of("Europe/Paris");
    Clock clock = Clock.system(zoneId_paris);
    Chronology chrono = Chronology.of("ThaiBuddhist");
    assertEquals(chrono.dateNow(), ThaiBuddhistChronology.INSTANCE.dateNow());
    assertEquals(chrono.dateNow(zoneId_paris), ThaiBuddhistChronology.INSTANCE.dateNow(zoneId_paris));
    assertEquals(chrono.dateNow(clock), ThaiBuddhistChronology.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)

Aggregations

Chronology (java.time.chrono.Chronology)202 IsoChronology (java.time.chrono.IsoChronology)171 ThaiBuddhistChronology (java.time.chrono.ThaiBuddhistChronology)116 MinguoChronology (java.time.chrono.MinguoChronology)112 HijrahChronology (java.time.chrono.HijrahChronology)107 JapaneseChronology (java.time.chrono.JapaneseChronology)104 Test (org.testng.annotations.Test)98 LocalDate (java.time.LocalDate)77 ChronoLocalDate (java.time.chrono.ChronoLocalDate)68 Test (org.junit.Test)40 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)27 TemporalAmount (java.time.temporal.TemporalAmount)24 TemporalUnit (java.time.temporal.TemporalUnit)24 TemporalField (java.time.temporal.TemporalField)21 DateTimeException (java.time.DateTimeException)18 Locale (java.util.Locale)17 TemporalAccessor (java.time.temporal.TemporalAccessor)15 ZoneId (java.time.ZoneId)13 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)13 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)12