本文整理汇总了Java中java.time.chrono.JapaneseDate.plus方法的典型用法代码示例。如果您正苦于以下问题:Java JapaneseDate.plus方法的具体用法?Java JapaneseDate.plus怎么用?Java JapaneseDate.plus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.chrono.JapaneseDate
的用法示例。
在下文中一共展示了JapaneseDate.plus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_JapaneseChrono_vsCalendar
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@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);
}
}