当前位置: 首页>>代码示例>>Java>>正文


Java LocalDate.isEqual方法代码示例

本文整理汇总了Java中java.time.LocalDate.isEqual方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.isEqual方法的具体用法?Java LocalDate.isEqual怎么用?Java LocalDate.isEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalDate的用法示例。


在下文中一共展示了LocalDate.isEqual方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.time.LocalDate; //导入方法依赖的package包/类
public static void main(String[] args) {
    /* Read and save input as LocalDates */
    Scanner scan = new Scanner(System.in);
    LocalDate returnDate = readDate(scan);
    LocalDate expectDate = readDate(scan);
    scan.close();
    
    /* Calculate fine */
    int fine;
    if (returnDate.isEqual(expectDate) || returnDate.isBefore(expectDate)) {
        fine = 0;
    } else if (returnDate.getMonth() == expectDate.getMonth() && returnDate.getYear() == expectDate.getYear()) {
        fine = 15 * (returnDate.getDayOfMonth() - expectDate.getDayOfMonth());
    } else if (returnDate.getYear() == expectDate.getYear()) {
        fine = 500 * (returnDate.getMonthValue() - expectDate.getMonthValue());
    } else {
        fine = 10000;
    }
    System.out.println(fine);
}
 
开发者ID:rshaghoulian,项目名称:HackerRank_solutions,代码行数:21,代码来源:Solution.java

示例2: updateSelectedDates

import java.time.LocalDate; //导入方法依赖的package包/类
private void updateSelectedDates() {
    List<LocalDate> dates = new ArrayList<>();

    LocalDate start = getSkinnable().getPageStartDate();

    do {
        dates.add(start);
        start = start.plusDays(1);
    }
    while (start.isBefore(getSkinnable().getPageEndDate()) || start.isEqual(getSkinnable().getPageEndDate()));

    calendarOne.getSelectedDates().clear();
    calendarOne.getSelectedDates().addAll(dates);

    calendarTwo.getSelectedDates().clear();
    calendarTwo.getSelectedDates().addAll(dates);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:18,代码来源:PrintablePageSkin.java

示例3: split

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Splits the given period into multiple slices of one month long.
 *
 * @param start the start of the period.
 * @param end   the end of the period.
 * @return The list of slices result of the splitting.
 */
public static List<Slice> split(LocalDate start, LocalDate end) {
    Objects.requireNonNull(start);
    Objects.requireNonNull(end);
    Preconditions.checkArgument(!start.isAfter(end));

    List<Slice> slices = Lists.newArrayList();

    LocalDate startOfMonth = start.withDayOfMonth(1);
    LocalDate endOfMonth = YearMonth.from(end).atEndOfMonth();

    do {
        slices.add(new Slice(startOfMonth, YearMonth.from(startOfMonth).atEndOfMonth()));
        startOfMonth = startOfMonth.plus(1, ChronoUnit.MONTHS);
    }
    while (startOfMonth.isBefore(endOfMonth) || startOfMonth.isEqual(endOfMonth));

    return slices;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:26,代码来源:Slice.java

示例4: onCheckOutDateSelected

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Validates the checkout date to ensure that it is at least one day after the checkin date.
 *
 * If it isn't, disables the room search button until it is.
 */
@FXML
private void onCheckOutDateSelected() {
    LocalDate checkOutDate = checkOutDatePicker.getValue();
    LocalDate checkInDate = checkInDatePicker.getValue();
    if(checkOutDate.isBefore(checkInDate) || checkOutDate.isEqual(checkInDate)) {
        checkOutDatePicker.getStyleClass().add("invalidField");
        checkOutDatePicker.setTooltip(
            new Tooltip("Checkout date cannot be on or before checkin date!")
        );
        findAvailableRoomsButton.setDisable(true);
    } else {
        checkOutDatePicker.getStyleClass().remove("invalidField");
        checkOutDatePicker.setTooltip(null);
        findAvailableRoomsButton.setDisable(false);
    }
    roomSearchResults.clear();
}
 
开发者ID:maillouxc,项目名称:git-rekt,代码行数:23,代码来源:BrowseRoomsScreenController.java

示例5: findIfLocalDateIsInRange

import java.time.LocalDate; //导入方法依赖的package包/类
private boolean findIfLocalDateIsInRange(String date1, String date2){

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
        LocalDate dateTime1 = LocalDate.parse(date1, formatter);
        LocalDate dateTime2 = LocalDate.parse(date2, formatter);

        LocalDate now = LocalDate.now();

        return (now.isEqual(dateTime1) || now.isEqual(dateTime2)) ||
               (dateTime1.isBefore(now) && dateTime2.isAfter(now));
    }
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:12,代码来源:ProgramIncrementServiceImpl.java

示例6: is2016ParxOaksDebacle

import java.time.LocalDate; //导入方法依赖的package包/类
public static boolean is2016ParxOaksDebacle(Track track, LocalDate raceDate,
        Integer raceNumber) {
    return (track != null && track.getCode() != null && raceDate != null &&
            raceNumber != null &&
            track.getCode().equals("PRX") &&
            raceDate.isEqual(LocalDate.of(2016, 5, 7)) &&
            raceNumber == 8);
}
 
开发者ID:robinhowlett,项目名称:chart-parser,代码行数:9,代码来源:ChartParser.java

示例7: split

import java.time.LocalDate; //导入方法依赖的package包/类
private void split() {
    LocalDate printStart = page.getPrintStartDate();
    LocalDate printEnd = page.getPrintEndDate();

    if (printStart == null || printEnd == null || printStart.isAfter(printEnd)) {
        // Just in case, should never happen!
        return;
    }

    PageSlice first = null;
    PageSlice pivot = null;
    LocalDate pageStartDate = printStart;
    int count = 0;

    do {
        LocalDate pageEndDate = pageStartDate.plus(1, page.getViewType().getChronoUnit()).minusDays(1);

        PageSlice next = new PageSlice(++count, pageStartDate, pageEndDate);

        if (first == null) {
            first = next;
        }

        if (pivot != null) {
            pivot.setNext(next);
        }

        pivot = next;
        pageStartDate = pageEndDate.plusDays(1);
    }
    while (pageStartDate.isBefore(printEnd) || pageStartDate.isEqual(printEnd));

    setSlice(first);
    page.setTotalPages(count);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:36,代码来源:PrintablePage.java

示例8: isIntersecting

import java.time.LocalDate; //导入方法依赖的package包/类
private boolean isIntersecting(LocalDate start, LocalDate end) {
    if ((start.isBefore(rangeStart) || start.isEqual(rangeStart)) && (end.isAfter(rangeEnd) || end.isEqual(rangeEnd))) {
        return true;
    }

    if ((start.isEqual(rangeStart) || start.isAfter(rangeStart)) && (start.isBefore(rangeEnd) || start.isEqual(rangeEnd))) {
        return true;
    }

    return (end.isEqual(rangeStart) || end.isAfter(rangeStart)) && (end.isBefore(rangeEnd) || end.isEqual(rangeEnd));

}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:13,代码来源:DateSelectionModel.java

示例9: 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

示例10: buildCells

import java.time.LocalDate; //导入方法依赖的package包/类
private void buildCells(YearMonth yearMonth, int colIndex) {
    List<Node> cells = new ArrayList<>();
    Node header = buildHeaderCell(yearMonth);
    header.getStyleClass().add("month-header");

    cells.add(header);

    LocalDate start = yearMonth.atDay(1);
    LocalDate end = yearMonth.atEndOfMonth();

    if (getSkinnable().getWeekDayLayout() == WeekDayLayoutStrategy.ALIGNED) {
        DayOfWeek firstDayOfWeek = getSkinnable().getFirstDayOfWeek();
        DayOfWeek startDayOfWeek = start.getDayOfWeek();
        int distanceDays = Math.abs(firstDayOfWeek.getValue() - startDayOfWeek.getValue());

        while (distanceDays-- > 0) {
            cells.add(buildCell(null));
        }
    }

    while (start.isBefore(end) || start.isEqual(end)) {
        cells.add(buildCell(start));
        start = start.plusDays(1);
    }

    buildEmptyCellBottom(cells);

    final YearMonth extendedStart = getSkinnable().getExtendedStartMonth();
    final YearMonth extendedEnd = getSkinnable().getExtendedEndMonth();

    cells.forEach(cell -> {
        if (extendedStart.equals(yearMonth)) {
            cell.getStyleClass().add("first-month");
        } else if (extendedEnd.equals(yearMonth)) {
            cell.getStyleClass().add("last-month");
        } else {
            cell.getStyleClass().add("middle-month");
        }
    });

    for (int i = 0; i < cells.size(); i++) {
        Node node = cells.get(i);
        grid.add(node, colIndex, i + 1);

        if (node instanceof DateCell) {

            final Position position = new Position(colIndex, i);
            final DateCell dateCell = (DateCell) node;
            final LocalDate date = dateCell.getDate();

            cellMap.put(date, dateCell);
            positionToDateCellMap.put(position, dateCell);
            dateToPositionMap.put(date, position);
        }
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:57,代码来源:MonthSheetViewSkin.java

示例11: updateUsageColors

import java.time.LocalDate; //导入方法依赖的package包/类
private void updateUsageColors(String reason) {
    cellsMap.values().forEach(control -> control.getStyleClass().removeAll(USAGE_VERY_LOW, USAGE_LOW, USAGE_MEDIUM, USAGE_HIGH, USAGE_VERY_HIGH));

    if (!getSkinnable().isShowUsageColors()) {
        return;
    }

    LoggingDomain.VIEW.fine("updating colors: reason = " + reason + ", year month = " + getSkinnable().getYearMonth());

    Map<LocalDate, List<Entry<?>>> dataMap = new HashMap<>();
    dataLoader.loadEntries(dataMap);

    for (String key : cellsMap.keySet()) {
        YearMonthView.DateCell cell = cellsMap.get(key);
        LocalDate date = cell.getDate();

        if (date.isEqual(getSkinnable().getToday()) && getSkinnable().isShowToday()) {
            continue;
        }

        int entryCount = 0;
        List<Entry<?>> entries = dataMap.get(date);
        if (entries != null) {
            entryCount = entries.size();
        }

        final Callback<Integer, DateControl.Usage> usagePolicy = getSkinnable().getUsagePolicy();

        switch (usagePolicy.call(entryCount)) {
            case NONE:
                break;
            case VERY_LOW:
                cell.getStyleClass().add(USAGE_VERY_LOW);
                break;
            case LOW:
                cell.getStyleClass().add(USAGE_LOW);
                break;
            case MEDIUM:
                cell.getStyleClass().add(USAGE_MEDIUM);
                break;
            case HIGH:
                cell.getStyleClass().add(USAGE_HIGH);
                break;
            case VERY_HIGH:
            default:
                cell.getStyleClass().add(USAGE_VERY_HIGH);
                break;
        }
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:51,代码来源:YearMonthViewSkin.java

示例12: updateActivityRectangles

import java.time.LocalDate; //导入方法依赖的package包/类
private void updateActivityRectangles(ObservableMap<LocalDate, Activity> activities) {

        rectangles = new ActivityRectangle[WEEKS][WEEKDAYS];

        LocalDate day = now().plusDays(WEEKDAYS - getWeekday(now()) - 1);

        int weekOffset = WEEKS - getWeek(day);

        int week;
        int weekday;

        int month = getMonth(day);

        do {

            week = (getWeek(day) + weekOffset - 1) % WEEKS;
            weekday = getWeekday(day);

            if (month != getMonth(day)) {
                monthLabelPositions[week] = month;
                month = getMonth(day);
            }

            rectangles[week][weekday] = new ActivityRectangle();

            ObservableList<String> styleClass = rectangles[week][weekday].getStyleClass();

            styleClass.add("week-activity-day");

            Activity activity = activities.get(day);
            if (activity != null) {

                rectangles[week][weekday].setActivity(activity);

                if (activity.getActivity() > 0.8f)
                    styleClass.add("week-activity-day-5");
                else if (activity.getActivity() > 0.6f)
                    styleClass.add("week-activity-day-4");
                else if (activity.getActivity() > 0.4f)
                    styleClass.add("week-activity-day-3");
                else if (activity.getActivity() > 0.2f)
                    styleClass.add("week-activity-day-2");
                else if (activity.getActivity() > 0.0f)
                    styleClass.add("week-activity-day-1");
            }

            // If today, add 'today' style class.
            if (day.isEqual(now()))
                styleClass.add("week-activity-today");

            // If day is in future, add 'future' style class.
            if (day.isAfter(now()))
                styleClass.add("week-activity-future");

            getChildren().addAll(rectangles[week][weekday]);

            day = day.minusDays(1);

        } while ((week > 0) || (weekday > 0));
    }
 
开发者ID:tbressler,项目名称:waterrower-workout,代码行数:61,代码来源:ActivityDiagramSkin.java


注:本文中的java.time.LocalDate.isEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。