當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalDate.plusYears方法代碼示例

本文整理匯總了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));
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:26,代碼來源:DateSelectionModelTests.java

示例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);
    }));
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:17,代碼來源:ColumnTests.java

示例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;
    }
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:9,代碼來源:StubGeneratorTest.java

示例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;
    }
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:10,代碼來源:TargetGeneratorTest.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKLocalDate.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKLocalDate.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKLocalDate.java


注:本文中的java.time.LocalDate.plusYears方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。