本文整理汇总了Java中java.time.calendrical.DateTime.PlusAdjuster方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.PlusAdjuster方法的具体用法?Java DateTime.PlusAdjuster怎么用?Java DateTime.PlusAdjuster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.calendrical.DateTime
的用法示例。
在下文中一共展示了DateTime.PlusAdjuster方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_badPlusAdjusterChrono
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Test(groups = { "tck" }, dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chrono chrono) {
LocalDate refDate = LocalDate.of(1900, 1, 1);
ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
for (Chrono[] clist : data_of_calendars()) {
Chrono chrono2 = clist[0];
ChronoZonedDateTime<?> czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
DateTime.PlusAdjuster adjuster = new FixedAdjuster(czdt2);
if (chrono != chrono2) {
try {
ChronoZonedDateTime<?> notreached = czdt.plus(adjuster);
Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + czdt + ", supplied: "
+ czdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoZonedDateTime<?> result = czdt.plus(adjuster);
assertEquals(result, czdt2, "WithAdjuster failed to replace date time");
}
}
}
示例2: test_badPlusAdjusterChrono
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Test(groups = { "tck" }, dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chrono chrono) {
LocalDate refDate = LocalDate.of(1900, 1, 1);
ChronoLocalDate date = chrono.date(refDate);
for (Chrono[] clist : data_of_calendars()) {
Chrono chrono2 = clist[0];
ChronoLocalDate<?> date2 = chrono2.date(refDate);
DateTime.PlusAdjuster adjuster = new FixedAdjuster(date2);
if (chrono != chrono2) {
try {
ChronoLocalDate<?> notreached = date.plus(adjuster);
Assert.fail("WithAdjuster should have thrown a ClassCastException");
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDate<?> result = date.plus(adjuster);
assertEquals(result, date2, "WithAdjuster failed to replace date");
}
}
}
示例3: test_badPlusAdjusterChrono
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Test(groups = { "tck" }, dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chrono chrono) {
LocalDate refDate = LocalDate.of(1900, 1, 1);
ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chrono[] clist : data_of_calendars()) {
Chrono chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
DateTime.PlusAdjuster adjuster = new FixedAdjuster(cdt2);
if (chrono != chrono2) {
try {
ChronoLocalDateTime<?> notreached = cdt.plus(adjuster);
Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + cdt + ", supplied: "
+ cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.plus(adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date time");
}
}
}