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