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


Java LocalDate.plusWeeks方法代碼示例

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


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

示例1: repeatTask

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * Repeats a task for a number of weeks.
 * @param repeatNumber The number of weeks to repeat the task.
 * @param homeworkTask The HomeworkTask to be repeated.
 * @param day The current day, to be able to calculate on what days to
 *            add the task.
 */
private void repeatTask(final int repeatNumber, final HomeworkTask homeworkTask, LocalDate day) {
    for (int i = 0; i < repeatNumber; i++) {
        // add one week to the day to put the task there
        LocalDate newDay = day.plusWeeks(1);
        // copy the task and its subtasks to the new day in the database
        Database.INSTANCE.copyAndInsertTask(newDay, homeworkTask);
    }
    // refresh the console to see the newly copied tasks
    controller.refreshAllDays();
}
 
開發者ID:deltadak,項目名稱:plep,代碼行數:18,代碼來源:CustomTreeCell.java

示例2: shouldSelectFromTodayUntilNextTwoWeeks

import java.time.LocalDate; //導入方法依賴的package包/類
@Test
public void shouldSelectFromTodayUntilNextTwoWeeks() {
    // Given
    LocalDate now = LocalDate.now();
    LocalDate nextWeek = now.plusWeeks(1);
    LocalDate nextWeekAfterNextWeek = nextWeek.plusWeeks(1);

    List<LocalDate> days = new ArrayList<>();
    LocalDate start = now;
    while (start.isBefore(nextWeekAfterNextWeek) || start.isEqual(nextWeekAfterNextWeek)) {
        days.add(start);
        start = start.plusDays(1);
    }

    DateSelectionModel model = new DateSelectionModel();
    model.setSelectionMode(SelectionMode.SINGLE_DATE_RANGE);

    // When
    model.select(now);
    model.selectUntil(nextWeek);
    model.selectUntil(nextWeekAfterNextWeek);

    // Then
    assertFalse(model.isEmpty());
    assertThat(model.getSelectedDates(), is(not(empty())));
    assertThat(model.getSelectedDates().size(), is(equalTo(days.size())));
    assertThat(model.getLastSelected(), is(equalTo(nextWeekAfterNextWeek)));

    for (LocalDate day : days) {
        assertTrue(model.isSelected(day));
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:33,代碼來源:DateSelectionModelTests.java

示例3: updateView

import java.time.LocalDate; //導入方法依賴的package包/類
private void updateView() {
    lastSelectedDate = null;

    YearMonthView view = getSkinnable();
    YearMonth yearMonth = view.getYearMonth();

    displayedYearMonth = yearMonth;

    boolean currentYearMonth = getSkinnable().getYearMonth().equals(YearMonth.from(getSkinnable().getToday()));

    monthLabel.getStyleClass().remove(CURRENT_DATE_LABEL);
    yearLabel.getStyleClass().remove(CURRENT_DATE_LABEL);

    if (currentYearMonth && view.isShowToday()) {
        monthLabel.getStyleClass().add(CURRENT_DATE_LABEL);
        yearLabel.getStyleClass().add(CURRENT_DATE_LABEL);
    }

    monthLabel.setText(DateTimeFormatter.ofPattern(Messages.getString("YearMonthViewSkin.MONTH_FORMAT")).format(yearMonth)); //$NON-NLS-1$
    yearLabel.setText(DateTimeFormatter.ofPattern(Messages.getString("YearMonthViewSkin.YEAR_FORMAT")).format(yearMonth)); //$NON-NLS-1$

    // update the week days (mon, tues, wed, ....)

    DayOfWeek dayOfWeek = view.getFirstDayOfWeek();
    for (int i = 0; i < 7; i++) {
        if (view.isShowToday()) {
            if (currentYearMonth) {
                dayOfWeekLabels[i].getStyleClass().add(CURRENT_DATE_BORDER);
            }
            if (currentYearMonth && view.getToday().getDayOfWeek().equals(dayOfWeek)) {
                dayOfWeekLabels[i].getStyleClass().add(CURRENT_DATE_LABEL);
            }
        }
    }


    // update the days (1 .. 31) plus padding days

    final DayOfWeek firstDayOfWeek = getSkinnable().getFirstDayOfWeek();
    LocalDate date = Util.adjustToFirstDayOfWeek(getLoadStartDate(), firstDayOfWeek);

    if (getSkinnable().isShowWeekNumbers()) {
        for (int i = 0; i < 6; i++) {
            int weekOfYear = date.get(getSkinnable().getWeekFields().weekOfYear());
            weekNumberLabels[i].setText(Integer.toString(weekOfYear));
            date = date.plusWeeks(1);
        }
    }

    date = Util.adjustToFirstDayOfWeek(getLoadStartDate(), firstDayOfWeek);

    for (int row = 0; row < 6; row++) {
        for (int col = 0; col < 7; col++) {
            LocalDate localDate = LocalDate.from(date);

            YearMonthView.DateCell cell = cellsMap.get(getKey(row, col));
            cell.setDate(localDate);
            cell.getStyleClass().removeAll(TODAY, DAY_OF_MONTH_LABEL, DAY_NOT_OF_MONTH_LABEL, WEEKEND_DAY, SELECTED_MONTH_DATE);

            if (getSkinnable().getSelectedDates().contains(date)) {
                cell.getStyleClass().add(SELECTED_MONTH_DATE); //$NON-NLS-1$
            }

            if (YearMonth.from(date).equals(YearMonth.from(getSkinnable().getDate()))) {
                if (getSkinnable().isShowToday() && date.equals(getSkinnable().getToday())) {
                    cell.getStyleClass().add(TODAY);
                } else {
                    cell.getStyleClass().add(DAY_OF_MONTH_LABEL); //$NON-NLS-1$
                }
            } else {
                cell.getStyleClass().add(DAY_NOT_OF_MONTH_LABEL); //$NON-NLS-1$
            }

            if (view.getWeekendDays().contains(date.getDayOfWeek())) {
                cell.getStyleClass().add(WEEKEND_DAY); //$NON-NLS-1$
            }

            date = date.plusDays(1);
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:82,代碼來源:YearMonthViewSkin.java


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