use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TCKHijrahChronology method test_resolve_yearOfEra_eraAndYearOfEraOnly_valid.
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, HijrahEra era) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, (long) era.getValue());
fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.ERA), null);
assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), null);
assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1343L);
assertEquals(fieldValues.size(), 1);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TCKHijrahChronology method test_resolve_ymd_smart.
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_smart(int y, int m, int d, HijrahDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (Boolean.TRUE.equals(smart)) {
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else if (smart instanceof HijrahDate) {
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, smart);
} else {
try {
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
fail("Should have failed, returned: " + date);
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_leapYears.
// Test to verify whether a given hijrah year is a leap year or not
@Test(dataProvider = "leapYears")
public void test_leapYears(int y, boolean leapyear) {
HijrahDate date = HijrahDate.of(y, 1, 1);
assertEquals(date.isLeapYear(), leapyear);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_Instant_zonedDateTime.
//-----------------------------------------------------------------------
// zonedDateTime(Instant, ZoneId )
//-----------------------------------------------------------------------
@Test
public void test_Instant_zonedDateTime() {
OffsetDateTime offsetDateTime = OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO);
ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH);
ChronoZonedDateTime<HijrahDate> result = HijrahChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset());
assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7));
assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));
result = HijrahChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset());
assertEquals(result.toLocalDate(), HijrahChronology.INSTANCE.date(1433, 4, 7));
assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1));
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_withDayOfYear.
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}
Aggregations