use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_adjust1.
//-----------------------------------------------------------------------
// with(WithAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_adjust1() {
JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 10, 29);
JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 10, 31));
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_isLeapYear.
@Test(dataProvider = "prolepticYear")
public void test_isLeapYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear);
assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear).isLeap());
JapaneseDate jdate = JapaneseDate.now();
jdate = jdate.with(ChronoField.YEAR, expectedProlepticYear).with(ChronoField.MONTH_OF_YEAR, 2);
if (isLeapYear) {
assertEquals(jdate.lengthOfMonth(), 29);
} else {
assertEquals(jdate.lengthOfMonth(), 28);
}
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_createByProleptic_isEqual.
@Test(dataProvider = "createByProleptic")
public void test_createByProleptic_isEqual(int y, int moy, int dom, int doy, LocalDate iso) {
JapaneseDate test = JapaneseDate.of(y, moy, dom);
assertEquals(test.isEqual(iso), true);
assertEquals(iso.isEqual(test), true);
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_ymd_strict.
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, JapaneseDate 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 (strict) {
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_yd_strict.
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, JapaneseDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
if (strict) {
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
Aggregations