use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_formatterOfLocalizedDate.
// Test to verify the localized dates using ofLocalizedDate() method
@Test(dataProvider = "chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_temporalDayAdjustments.
// Test to get the adjusted date from a given date using TemporalAdjuster methods
@Test
public void test_temporalDayAdjustments() {
HijrahDate date = HijrahDate.of(1554, 7, 21);
assertEquals(date.with(TemporalAdjusters.firstDayOfMonth()), HijrahDate.of(1554, 7, 1));
assertEquals(date.with(TemporalAdjusters.lastDayOfMonth()), HijrahDate.of(1554, 7, 29));
assertEquals(date.with(TemporalAdjusters.firstDayOfNextMonth()), HijrahDate.of(1554, 8, 1));
assertEquals(date.with(TemporalAdjusters.firstDayOfNextYear()), HijrahDate.of(1555, 1, 1));
assertEquals(date.with(TemporalAdjusters.firstDayOfYear()), HijrahDate.of(1554, 1, 1));
assertEquals(date.with(TemporalAdjusters.lastDayOfYear()), HijrahDate.of(1554, 12, 30));
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_withDayOfYearTooLarge.
@Test(expectedExceptions = java.time.DateTimeException.class)
public void test_withDayOfYearTooLarge() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_withDayOfYearTooSmall.
@Test(expectedExceptions = java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TCKHijrahChronology method test_resolve_yearOfEra_yearOfEraOnly_valid.
@Test(dataProvider = "resolve_styles")
public void test_resolve_yearOfEra_yearOfEraOnly_valid(ResolverStyle style) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR_OF_ERA, 1343L);
HijrahDate date = HijrahChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (style != ResolverStyle.STRICT) ? null : (Long) 1343L);
assertEquals(fieldValues.get(ChronoField.YEAR), (style == ResolverStyle.STRICT) ? null : (Long) 1343L);
assertEquals(fieldValues.size(), 1);
}
Aggregations