use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_lastDayOfMonth.
// Test to get the last day of the month by adjusting the date with lastDayOfMonth() method
@Test(dataProvider = "monthDays")
public void test_lastDayOfMonth(int year, int month, int numDays) {
HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1);
hDate = hDate.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestExampleCode method test_library.
@Test
public void test_library() {
HijrahDate date = HijrahDate.now();
HijrahDate next = next(date);
ChronoLocalDateTime<HijrahDate> noonTomorrow = tomorrowNoon(date);
HijrahDate hd3 = noonTomorrow.toLocalDate();
System.out.printf(" now: %s, noon tomorrow: %s%n", date, noonTomorrow);
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestExampleCode method HijrahExample1.
void HijrahExample1() {
HijrahDate hd2 = HijrahChronology.INSTANCE.date(1200, 1, 1);
ChronoLocalDateTime<HijrahDate> hdt = hd2.atTime(LocalTime.MIDNIGHT);
ChronoZonedDateTime<HijrahDate> zhdt = hdt.atZone(ZoneId.of("GMT"));
HijrahDate hd3 = zhdt.toLocalDate();
ChronoLocalDateTime<HijrahDate> hdt2 = zhdt.toLocalDateTime();
HijrahDate hd4 = hdt2.toLocalDate();
HijrahDate hd5 = next(hd2);
}
use of java.time.chrono.HijrahDate 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
}
}
use of java.time.chrono.HijrahDate in project jdk8u_jdk by JetBrains.
the class TestUmmAlQuraChronology method test_getDayOfYear.
//-----------------------------------------------------------------------
// HijrahDate.with(DAY_OF_YEAR, n)
//-----------------------------------------------------------------------
@Test
public void test_getDayOfYear() {
HijrahDate hd1 = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd1.lengthOfYear(); i++) {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, i);
int doy = hd.get(DAY_OF_YEAR);
assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i);
}
}
Aggregations