当前位置: 首页>>代码示例>>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;未经允许,请勿转载。