use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_createByEra_dateFrom.
@Test(dataProvider = "createByEra")
public void test_createByEra_dateFrom(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
assertEquals(LocalDate.from(test), iso);
assertEquals(JapaneseDate.from(iso), test);
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_LocalDate_adjustToJapaneseDate.
//-----------------------------------------------------------------------
// LocalDate.with(JapaneseDate)
//-----------------------------------------------------------------------
@Test
public void test_LocalDate_adjustToJapaneseDate() {
JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1928, 10, 29);
LocalDate test = LocalDate.MIN.with(jdate);
assertEquals(test, LocalDate.of(1928, 10, 29));
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_yd_smart.
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(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 (smart) {
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
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_createByProleptic_query.
@Test(dataProvider = "createByProleptic")
public void test_createByProleptic_query(int y, int moy, int dom, int doy, LocalDate iso) {
JapaneseDate test = JapaneseDate.of(y, moy, dom);
assertEquals(test.query(TemporalQueries.localDate()), iso);
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_eymd.
@Test(dataProvider = "resolve_eymd")
public void test_resolve_eymd(ResolverStyle style, JapaneseEra era, int yoe, int m, int d, JapaneseDate expected) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, (long) era.getValue());
fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (expected != null) {
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
Aggregations