本文整理汇总了Java中java.time.LocalDate.plusYears方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.plusYears方法的具体用法?Java LocalDate.plusYears怎么用?Java LocalDate.plusYears使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDate
的用法示例。
在下文中一共展示了LocalDate.plusYears方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldSelectMultipleDates
import java.time.LocalDate; //导入方法依赖的package包/类
@Test
public void shouldSelectMultipleDates() {
// Given
LocalDate now = LocalDate.now();
LocalDate tomorrow = now.plusDays(1);
LocalDate dayAfterTomorrow = tomorrow.plusDays(1);
LocalDate oneYearAfter = dayAfterTomorrow.plusYears(1);
DateSelectionModel model = new DateSelectionModel();
model.setSelectionMode(SelectionMode.MULTIPLE_DATES);
// When
model.selectRange(now, dayAfterTomorrow);
model.select(oneYearAfter);
// Then
assertFalse(model.isEmpty());
assertThat(model.getSelectedDates(), is(not(empty())));
assertThat(model.getSelectedDates().size(), is(equalTo(4)));
assertThat(model.getSelectedDates(), contains(now, tomorrow, dayAfterTomorrow, oneYearAfter));
assertThat(model.getLastSelected(), is(equalTo(oneYearAfter)));
assertTrue(model.isSelected(now));
assertTrue(model.isSelected(tomorrow));
assertTrue(model.isSelected(dayAfterTomorrow));
assertTrue(model.isSelected(oneYearAfter));
}
示例2: testFilter1
import java.time.LocalDate; //导入方法依赖的package包/类
@Test()
public void testFilter1() {
final LocalDate start = LocalDate.of(2000, 1, 1);
final LocalDate end = start.plusYears(10);
final Index<LocalDate> dates = Range.of(start, end).toIndex(LocalDate.class);
final Index<String> strings = Range.of(0, 100).map(i -> "Column-" +i).toIndex(String.class);
final DataFrame<String,LocalDate> frame = DataFrame.ofDoubles(strings, dates);
frame.applyDoubles(v -> Math.random() * 100);
final DataFrameColumns<String,LocalDate> filter = frame.cols().filter(Arrays.asList(dates.getKey(0), dates.getKey(25), dates.getKey(102), dates.getKey(456)));
Assert.assertEquals(filter.count(), 4, "Column count matches expected column count");
filter.forEach(column -> column.forEachValue(v -> {
final double actual = v.getDouble();
final double expected = frame.data().getDouble(v.rowKey(), v.colKey());
Assert.assertEquals(actual, expected, "The value matches for " + v);
}));
}
示例3: call
import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LocalDate call(LocalDate payload) {
if ("banan".equals(headers.getHeaderString(Constants.USERTOKENID_HEADER))) {
return payload.plusYears(1);
} else {
return payload;
}
}
示例4: call
import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LocalDate call(LocalDate payload) {
String usertoken = headers.getHeaderString(Constants.USERTOKENID_HEADER);
if ("banan".equals(usertoken)) {
return payload.plusYears(1);
} else {
return payload;
}
}
示例5: test_plusYears_long_invalidTooLarge
import java.time.LocalDate; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_plusYears_long_invalidTooLarge() {
LocalDate test = LocalDate.of(Year.MAX_VALUE, 6, 1);
test.plusYears(1);
}
示例6: test_plusYears_long_invalidTooLargeMaxAddMax
import java.time.LocalDate; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_plusYears_long_invalidTooLargeMaxAddMax() {
LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
test.plusYears(Long.MAX_VALUE);
}
示例7: test_plusYears_long_invalidTooLargeMaxAddMin
import java.time.LocalDate; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_plusYears_long_invalidTooLargeMaxAddMin() {
LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
test.plusYears(Long.MIN_VALUE);
}