Search in sources :

Example 6 with HijrahChronology

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
    }
}
Also used : ValueRange(java.time.temporal.ValueRange) HijrahDate(java.time.chrono.HijrahDate) DateTimeException(java.time.DateTimeException) HijrahChronology(java.time.chrono.HijrahChronology) Test(org.testng.annotations.Test)

Aggregations

HijrahChronology (java.time.chrono.HijrahChronology)6 Test (org.testng.annotations.Test)6 ValueRange (java.time.temporal.ValueRange)3 HijrahDate (java.time.chrono.HijrahDate)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 DateTimeException (java.time.DateTimeException)1 ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 Chronology (java.time.chrono.Chronology)1 Era (java.time.chrono.Era)1 HijrahEra (java.time.chrono.HijrahEra)1 IsoChronology (java.time.chrono.IsoChronology)1 AbstractTCKTest (tck.java.time.AbstractTCKTest)1