use of java.time.chrono.HijrahChronology in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_hijrahDateLimits.
// Check the date limits
@Test
public void test_hijrahDateLimits() {
HijrahChronology chrono = HijrahChronology.INSTANCE;
ValueRange yearRange = chrono.range(YEAR);
ValueRange monthRange = chrono.range(MONTH_OF_YEAR);
ValueRange dayRange = chrono.range(DAY_OF_MONTH);
HijrahDate xx = chrono.date(1434, 1, 1);
HijrahDate minDate = chrono.date((int) yearRange.getLargestMinimum(), (int) monthRange.getMinimum(), (int) dayRange.getMinimum());
try {
HijrahDate before = minDate.minus(1, ChronoUnit.DAYS);
fail("Exception did not occur, minDate: " + minDate + ".minus(1, DAYS) = " + before);
} catch (DateTimeException ex) {
// ignore, this exception was expected
}
HijrahDate maxDate = chrono.date((int) yearRange.getSmallestMaximum(), (int) monthRange.getMaximum(), 1);
int monthLen = maxDate.lengthOfMonth();
maxDate = maxDate.with(DAY_OF_MONTH, monthLen);
try {
HijrahDate after = maxDate.plus(1, ChronoUnit.DAYS);
fail("Exception did not occur, maxDate: " + maxDate + ".plus(1, DAYS) = " + after);
} catch (DateTimeException ex) {
// ignore, this exception was expected
}
}
Aggregations