use of java.time.chrono.ChronoLocalDate in project jdk8u_jdk by JetBrains.
the class TCKHijrahChronology 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 HijrahChronology) {
continue;
}
List<Era> eras = chrono.eras();
for (Era era : eras) {
try {
ChronoLocalDate date = HijrahChronology.INSTANCE.date(era, 1, 1, 1);
fail("HijrahChronology.date did not throw ClassCastException for Era: " + era);
} catch (ClassCastException cex) {
// ignore expected exception
;
}
try {
@SuppressWarnings("unused") int year = HijrahChronology.INSTANCE.prolepticYear(era, 1);
fail("HijrahChronology.prolepticYear did not throw ClassCastException for Era: " + era);
} catch (ClassCastException cex) {
// ignore expected exception
;
}
}
}
}
use of java.time.chrono.ChronoLocalDate in project jdk8u_jdk by JetBrains.
the class TCKChronology method test_IsoChronology_dateYearDay.
@Test
public void test_IsoChronology_dateYearDay() {
Chronology chrono = Chronology.of("ISO");
ChronoLocalDate date1 = chrono.dateYearDay(IsoEra.CE, 5, 60);
ChronoLocalDate date2 = chrono.date(IsoEra.CE, 5, 3, 1);
assertEquals(date1, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
assertEquals(date2, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
}
use of java.time.chrono.ChronoLocalDate in project jdk8u_jdk by JetBrains.
the class TCKChronoPeriod method test_subtractFrom.
@Test(dataProvider = "calendars")
public void test_subtractFrom(Chronology chrono) {
ChronoPeriod period = chrono.period(1, 2, 3);
ChronoLocalDate date = chrono.dateNow();
Temporal result = period.subtractFrom(date);
assertEquals(result, date.minus(14, MONTHS).minus(3, DAYS));
}
use of java.time.chrono.ChronoLocalDate 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);
}
use of java.time.chrono.ChronoLocalDate 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));
}
Aggregations