當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。