本文整理匯總了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");
}
}
}