本文整理汇总了Java中java.time.chrono.JapaneseDate.with方法的典型用法代码示例。如果您正苦于以下问题:Java JapaneseDate.with方法的具体用法?Java JapaneseDate.with怎么用?Java JapaneseDate.with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.chrono.JapaneseDate
的用法示例。
在下文中一共展示了JapaneseDate.with方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_with_TemporalField_long
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@Test
public void test_with_TemporalField_long() {
JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30);
JapaneseDate test = base.with(YEAR, 1987);
assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30));
test = test.with(YEAR_OF_ERA, 2);
assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30));
test = test.with(ERA, JapaneseEra.HEISEI.getValue());
assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30));
test = test.with(MONTH_OF_YEAR, 3);
assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30));
test = test.with(DAY_OF_MONTH, 4);
assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4));
}
示例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);
}
}
示例3: test_adjust1
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@Test
public void test_adjust1() {
JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 10, 29);
JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 10, 31));
}
示例4: test_adjust2
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@Test
public void test_adjust2() {
JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 12, 2);
JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 12, 31));
}
示例5: test_adjust_toLocalDate
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@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));
}
示例6: test_adjust_toMonth
import java.time.chrono.JapaneseDate; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_adjust_toMonth() {
JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1926, 1, 4);
jdate.with(Month.APRIL);
}