本文整理汇总了Java中java.time.chrono.ChronoLocalDate.plus方法的典型用法代码示例。如果您正苦于以下问题:Java ChronoLocalDate.plus方法的具体用法?Java ChronoLocalDate.plus怎么用?Java ChronoLocalDate.plus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.chrono.ChronoLocalDate
的用法示例。
在下文中一共展示了ChronoLocalDate.plus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_badPlusAdjusterChrono
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@Test(dataProvider="calendars")
public void test_badPlusAdjusterChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDate date = chrono.date(refDate);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDate date2 = chrono2.date(refDate);
TemporalAmount adjuster = new FixedAdjuster(date2);
if (chrono != chrono2) {
try {
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");
}
}
}
示例2: test_badPlusTemporalUnitChrono
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@Test(dataProvider="calendars")
public void test_badPlusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDate date = chrono.date(refDate);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDate date2 = chrono2.date(refDate);
TemporalUnit adjuster = new FixedTemporalUnit(date2);
if (chrono != chrono2) {
try {
date.plus(1, adjuster);
Assert.fail("TemporalUnit.doAdd plus should have thrown a ClassCastException" + date.getClass()
+ ", can not be cast to " + date2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDate result = date.plus(1, adjuster);
assertEquals(result, date2, "WithAdjuster failed to replace date");
}
}
}
示例3: ofWeekBasedYear
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
/**
* Return a new week-based-year date of the Chronology, year, week-of-year,
* and dow of week.
* @param chrono The chronology of the new date
* @param yowby the year of the week-based-year
* @param wowby the week of the week-based-year
* @param dow the day of the week
* @return a ChronoLocalDate for the requested year, week of year, and day of week
*/
private ChronoLocalDate ofWeekBasedYear(Chronology chrono,
int yowby, int wowby, int dow) {
ChronoLocalDate date = chrono.date(yowby, 1, 1);
int ldow = localizedDayOfWeek(date);
int offset = startOfWeekOffset(1, ldow);
// Clamp the week of year to keep it in the same year
int yearLen = date.lengthOfYear();
int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek());
wowby = Math.min(wowby, newYearWeek - 1);
int days = -offset + (dow - 1) + (wowby - 1) * 7;
return date.plus(days, DAYS);
}
示例4: test_valueRange_monthDays
import java.time.chrono.ChronoLocalDate; //导入方法依赖的package包/类
@Test (dataProvider="monthDays")
public void test_valueRange_monthDays(int year, int month, int maxlength) {
ChronoLocalDate date = HijrahChronology.INSTANCE.date(year, month, 1);
ValueRange range = null;
for (int i=1; i<=12; i++) {
range = date.range(ChronoField.DAY_OF_MONTH);
date = date.plus(1, ChronoUnit.MONTHS);
assertEquals(range.getMaximum(), month, maxlength);
}
}