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


Java LocalDate.minus方法代碼示例

本文整理匯總了Java中java.time.LocalDate.minus方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalDate.minus方法的具體用法?Java LocalDate.minus怎麽用?Java LocalDate.minus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.LocalDate的用法示例。


在下文中一共展示了LocalDate.minus方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testRangeOfLocalDates

import java.time.LocalDate; //導入方法依賴的package包/類
@Test(dataProvider = "localDateRanges")
public void testRangeOfLocalDates(LocalDate start, LocalDate end, Period step, boolean parallel) {
    final Range<LocalDate> range = Range.of(start, end, step);
    final Array<LocalDate> array = range.toArray(parallel);
    final boolean ascend = start.isBefore(end);
    final int expectedLength = (int)Math.ceil(Math.abs((double)ChronoUnit.DAYS.between(start, end)) / (double)step.getDays());
    Assert.assertEquals(array.length(), expectedLength);
    Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_DATE);
    Assert.assertTrue(!array.style().isSparse());
    Assert.assertEquals(range.start(), start, "The range start");
    Assert.assertEquals(range.end(), end, "The range end");
    LocalDate expected = null;
    for (int i=0; i<array.length(); ++i) {
        final LocalDate actual = array.getValue(i);
        expected = expected == null ? start : ascend ? expected.plus(step) : expected.minus(step);
        Assert.assertEquals(actual, expected, "Value matches at " + i);
        Assert.assertTrue(ascend ? actual.compareTo(start) >=0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + i);
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:20,代碼來源:RangeBasicTests.java

示例2: testRangeOfLocalDates

import java.time.LocalDate; //導入方法依賴的package包/類
@Test(dataProvider = "LocalDateRanges")
public void testRangeOfLocalDates(LocalDate start, LocalDate end, Period step, boolean parallel) {
    final boolean ascend = start.isBefore(end);
    final Range<LocalDate> range = Range.of(start, end, step, v -> v.getDayOfWeek() == DayOfWeek.MONDAY);
    final Array<LocalDate> array = range.toArray(parallel);
    final LocalDate first = array.first(v -> true).map(ArrayValue::getValue).get();
    final LocalDate last = array.last(v -> true).map(ArrayValue::getValue).get();
    Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_DATE);
    Assert.assertTrue(!array.style().isSparse());
    Assert.assertEquals(range.start(), start, "The range start");
    Assert.assertEquals(range.end(), end, "The range end");
    int index = 0;
    LocalDate value = first;
    while (ascend ? value.isBefore(last) : value.isAfter(last)) {
        final LocalDate actual = array.getValue(index);
        Assert.assertEquals(actual, value, "Value matches at " + index);
        Assert.assertTrue(ascend ? actual.compareTo(start) >= 0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + index);
        value = ascend ? value.plus(step) : value.minus(step);
        while (value.getDayOfWeek() == DayOfWeek.MONDAY) value = ascend ? value.plus(step) : value.minus(step);
        index++;
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:23,代碼來源:RangeFilterTests.java

示例3: bepaalDatum

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * bepaald de nieuwe datum door van de meegegeven datum het aantal meegegeven dagen af te trekken
 * @param datum peilDatum
 * @param minus aantal dagen voor peildatum
 * @return bepaalde datum
 */
public static Integer bepaalDatum(final int datum, final int minus) {
    final Integer minimaleDatum = bepaalEindDatumStrengOfBeginDatumSoepel(datum, false);
    final LocalDate minimaleDate = vanIntegerNaarLocalDate(minimaleDatum);
    final LocalDate nieuweDate = minimaleDate.minus(minus, ChronoUnit.DAYS);
    final String formattedDateString = FORMATTER.format(nieuweDate);
    return Integer.parseInt(formattedDateString);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:14,代碼來源:DatumUtil.java

示例4: initialize

import java.time.LocalDate; //導入方法依賴的package包/類
@Override
public void initialize(URL location, ResourceBundle resources) {

    diag = new Dialog();

    diag.getDialogPane().setContent(borderPane);
    diag.getDialogPane().setBackground(Background.EMPTY);
    diag.setResizable(true);

    UIUtils.setIcon(diag);

    diag.setTitle("Export senor data to CSV");

    // date
    endPicker.disableProperty().bind(nowCheck.selectedProperty());
    dateInput.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(newValue);
            dateLabel.setText(sdf.format(new Date()));
            validFormat.set(true);
        } catch (IllegalArgumentException ex) {
            dateLabel.setText("Invalid format!");
            validFormat.set(false);
        }
    });
    // trigger
    String cur = dateInput.getText();
    dateInput.textProperty().set("");
    dateInput.textProperty().set(cur);

    endPicker.setValue(LocalDate.now());
    LocalDate s = LocalDate.now();
    s = s.minus(7, ChronoUnit.DAYS);
    startPicker.setValue(s);

    // Bug: can not bind same data on 2 lists
    sensorList.getItems().addAll(store.getSensors());
    sensorList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        sensorSelected.set(newValue != null);
    });

    canExport.bind(sensorSelected.and(validFormat));

    ButtonType closeButton = new ButtonType("Close", ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType exportButton = new ButtonType("Export", ButtonBar.ButtonData.OK_DONE);
    diag.getDialogPane().getButtonTypes().addAll(closeButton, exportButton);
    diag.getDialogPane().lookupButton(exportButton).disableProperty().bind(canExport.not());

    showDialog();
}
 
開發者ID:dainesch,項目名稱:HueSense,代碼行數:51,代碼來源:ExportPresenter.java

示例5: getPreviousDay

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * 獲取前 i 天日期
 *
 * @return
 */
public static LocalDate getPreviousDay ( int i ) {
    LocalDate today = LocalDate.now();
    return today.minus( i , ChronoUnit.DAYS );
}
 
開發者ID:yujunhao8831,項目名稱:spring-boot-start-current,代碼行數:10,代碼來源:DateUtils.java


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