use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method test_periodUntilDiffChrono.
@Test
public void test_periodUntilDiffChrono() {
JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
ChronoPeriod period = mdate1.until(ldate2);
assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1));
}
use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.
the class TestJapaneseChronoImpl method test_dayOfYearVsCalendar.
//-----------------------------------------------------------------------
// Verify Japanese Calendar matches java.util.Calendar for number of days
// in years 1 and 2.
//-----------------------------------------------------------------------
@Test
public void test_dayOfYearVsCalendar() {
Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese");
Calendar cal = java.util.Calendar.getInstance(locale);
for (JapaneseEra era : JapaneseEra.values()) {
for (int year : new int[] { 6, 7 }) {
JapaneseDate jd = JapaneseChronology.INSTANCE.dateYearDay(era, year, 1);
OffsetDateTime jodt = OffsetDateTime.of(LocalDate.from(jd), LocalTime.MIN, ZoneOffset.UTC);
long millis = jodt.toInstant().toEpochMilli();
cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
cal.setTimeInMillis(millis);
assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year);
assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year);
assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year);
}
}
}
Aggregations