use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TestJapaneseChronoImpl method test_JapaneseChrono_vsCalendar.
//-----------------------------------------------------------------------
// Verify Japanese Calendar matches java.util.Calendar for range
//-----------------------------------------------------------------------
@Test(dataProvider = "RangeVersusCalendar")
public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) {
Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese");
assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale");
Calendar cal = java.util.Calendar.getInstance(locale);
assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type");
JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate);
// Convert to millis and set Japanese Calendar to that start date (at GMT)
OffsetDateTime jodt = OffsetDateTime.of(isoStartDate, LocalTime.MIN, ZoneOffset.UTC);
long millis = jodt.toInstant().toEpochMilli();
cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
cal.setTimeInMillis(millis);
while (jDate.isBefore(isoEndDate)) {
assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal);
assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate);
assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate);
jDate = jDate.plus(1, ChronoUnit.DAYS);
cal.add(Calendar.DAY_OF_MONTH, 1);
}
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_resolve_yearOfEra_eraAndYearOfEraOnly_valid.
@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, JapaneseEra era) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.ERA, (long) era.getValue());
fieldValues.put(ChronoField.YEAR_OF_ERA, 1L);
JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
assertEquals(date, null);
assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L);
assertEquals(fieldValues.size(), 2);
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_adjust_toLocalDate.
//-----------------------------------------------------------------------
// JapaneseDate.with(Local*)
//-----------------------------------------------------------------------
@Test
public void test_adjust_toLocalDate() {
JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1926, 1, 4);
JapaneseDate test = jdate.with(LocalDate.of(2012, 7, 6));
assertEquals(test, JapaneseChronology.INSTANCE.date(2012, 7, 6));
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_createByProleptic_epochDay.
@Test(dataProvider = "createByProleptic")
public void test_createByProleptic_epochDay(int y, int moy, int dom, int doy, LocalDate iso) {
JapaneseDate test = JapaneseDate.of(y, moy, dom);
assertEquals(test.getLong(EPOCH_DAY), iso.getLong(EPOCH_DAY));
assertEquals(test.toEpochDay(), iso.toEpochDay());
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_createByProleptic_chronologyTemporalFactory.
@Test(dataProvider = "createByProleptic")
public void test_createByProleptic_chronologyTemporalFactory(int y, int moy, int dom, int doy, LocalDate iso) {
JapaneseDate test = JapaneseDate.of(y, moy, dom);
assertEquals(IsoChronology.INSTANCE.date(test), iso);
assertEquals(JapaneseChronology.INSTANCE.date(iso), test);
}
Aggregations