本文整理汇总了Java中java.time.chrono.JapaneseDate.get方法的典型用法代码示例。如果您正苦于以下问题:Java JapaneseDate.get方法的具体用法?Java JapaneseDate.get怎么用?Java JapaneseDate.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.chrono.JapaneseDate
的用法示例。
在下文中一共展示了JapaneseDate.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_getDayOfYear
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@Test
public void test_getDayOfYear() {
// Test all the Eras
for (JapaneseEra era : JapaneseEra.values()) {
int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1; // Until Era supports range(YEAR_OF_ERA)
JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1);
ValueRange range = hd1.range(DAY_OF_YEAR);
assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()");
for (int i = 1; i <= hd1.lengthOfYear(); i++) {
JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i);
int doy = hd.get(DAY_OF_YEAR);
assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd);
}
}
}
示例2: test_withDayOfYear
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@Test
public void test_withDayOfYear() {
JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(1990, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
JapaneseDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}