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


Java LocalTime.isAfter方法代碼示例

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


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

示例1: updateUsedTimes

import java.time.LocalTime; //導入方法依賴的package包/類
private void updateUsedTimes() {
    LocalTime earliestTime = null;
    LocalTime latestTime = null;

    for (WeekDayView view : getSkinnable().getWeekDayViews()) {

        LocalTime etu = view.getEarliestTimeUsed();
        LocalTime ltu = view.getLatestTimeUsed();

        if (earliestTime == null || (etu != null && etu.isBefore(earliestTime))) {
            earliestTime = etu;
        }

        if (latestTime == null || (ltu != null && ltu.isAfter(latestTime))) {
            latestTime = ltu;
        }
    }

    getSkinnable().getProperties().put("earliest.time.used", earliestTime);
    getSkinnable().getProperties().put("latest.time.used", latestTime);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:22,代碼來源:WeekViewSkin.java

示例2: testRangeOfLocalTimes

import java.time.LocalTime; //導入方法依賴的package包/類
@Test(dataProvider = "LocalTimeRanges")
public void testRangeOfLocalTimes(LocalTime start, LocalTime end, Duration step, boolean parallel) {
    final boolean ascend = start.isBefore(end);
    final Range<LocalTime> range = Range.of(start, end, step, v -> v.getHour() == 6);
    final Array<LocalTime> array = range.toArray(parallel);
    final LocalTime first = array.first(v -> true).map(ArrayValue::getValue).get();
    final LocalTime last = array.last(v -> true).map(ArrayValue::getValue).get();
    Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_TIME);
    Assert.assertTrue(!array.style().isSparse());
    Assert.assertEquals(range.start(), start, "The range start");
    Assert.assertEquals(range.end(), end, "The range end");
    int index = 0;
    LocalTime value = first;
    while (ascend ? value.isBefore(last) : value.isAfter(last)) {
        final LocalTime 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.getHour() == 6) value = ascend ? value.plus(step) : value.minus(step);
        index++;
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:23,代碼來源:RangeFilterTests.java

示例3: validate

import java.time.LocalTime; //導入方法依賴的package包/類
@Override
protected boolean validate() {
    LocalDate today = LocalDate.now();
    LocalTime start = startTime.getValue();
    LocalTime end = endTime.getValue();

    if(name.getText().isEmpty()){
        MessageHelper.showErrorAlertMessage("The Name is missing.");
        name.requestFocus();
        return false;
    } else if(date.getValue() == null || date.getValue().isBefore(today) ){
        MessageHelper.showErrorAlertMessage("The date is not valid.");
        date.requestFocus();
        return false;
    } else if(start == null) {
        MessageHelper.showErrorAlertMessage("The starttime is missing.");
        return false;
    } else if(end != null && (start.isAfter(end) || start.equals(end))) {
        MessageHelper.showErrorAlertMessage("The endtime is not after the starttime.");
        return false;
    } else if(date.getValue().equals(today) && start.isBefore(LocalTime.now())){
        MessageHelper.showErrorAlertMessage("The starttime must be in future.");
        return false;
    }
    return true;
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:27,代碼來源:CreateRehearsalController.java

示例4: withinTimeSpan

import java.time.LocalTime; //導入方法依賴的package包/類
public static boolean withinTimeSpan(LocalTime startTime, LocalTime endTime, LocalTime timepoint) {
    if (startTime.isBefore(endTime)) {
        // timespan is wihtin a day
        return (timepoint.isAfter(startTime) || timepoint.equals(startTime))
                && (timepoint.isBefore(endTime) || timepoint.equals(endTime));
    } else {
        // timespan is not within a day (through midnight, e.g.  23:30 - 0:15)
        return (timepoint.isAfter(startTime) || timepoint.equals(startTime))
                || (timepoint.isBefore(endTime) || timepoint.equals(endTime));
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:12,代碼來源:TimestampUtils.java

示例5: createLabels

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Creates or updates the actual layout of the time axis.
 * The layout can either be horizontal or vertical.
 * The GridView is populated with columns/rows and labels are added accordingly.
 * The labels show the time between this.timeStartProperty and this.timeEndProperty with
 * this.timeStepsProperty in between.
 * The time is formatted according to this.formatter.
 */
private void createLabels() {
    this.getChildren().clear();
    this.getRowConstraints().clear();
    this.getColumnConstraints().clear();

    for(LocalTime currentTime = getTimeStartProperty().get();
        currentTime.isBefore(getTimeEndProperty().get()); ) {

        // create a new label with the time
        Label lblTime = new Label();
        lblTime.setText(currentTime.format(getFormatter()));
        lblTime.getStyleClass().add("time-axis-label");

        // create a new row/column and add the label to it
        if(horizontal) {
            // center the label
            lblTime.widthProperty().addListener(o -> lblTime.setTranslateX( -lblTime.widthProperty().getValue() / 2));

            ColumnConstraints column = new ColumnConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, HPos.LEFT, true);
            this.getColumnConstraints().add(column);
            this.add(lblTime, this.getColumnConstraints().size() - 1, 0);
        } else {
            // center the label
            lblTime.heightProperty().addListener(o -> lblTime.setTranslateY( -lblTime.heightProperty().getValue() / 2));
            RowConstraints row = new RowConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, VPos.TOP, true);
            this.getRowConstraints().add(row);
            this.add(lblTime, 0, this.getRowConstraints().size() - 1);
        }

        // prevent overflows at midnight
        LocalTime newTime = currentTime.plusMinutes(getTimeStepsProperty().get().toMinutes());
        if(newTime.isAfter(currentTime)) {
            currentTime = newTime;
        } else {
            break;
        }
    }
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:47,代碼來源:TimeAxis.java

示例6: createEntries

import java.time.LocalTime; //導入方法依賴的package包/類
public void createEntries() {
    calendar.setStyle(Calendar.Style.getStyle(style++));
    calendar.clear();

    LocalTime dailyStartTime = LocalTime.of(8, 0);
    LocalTime dailyEndTime = LocalTime.of(20, 0);

    LocalDate entryDate = LocalDate.now();
    LocalTime entryTime = dailyStartTime;

    long startTime = System.currentTimeMillis();
    int count = comboBox.getValue();

    calendar.startBatchUpdates();

    for (int i = 0; i < count; i++) {
        Entry<String> entry = new Entry<>("Entry " + i);
        entry.setInterval(new Interval(entryDate, entryTime, entryDate, entryTime.plusMinutes(30)));
        entryTime = entryTime.plusHours(1);
        if (entryTime.isAfter(dailyEndTime)) {
            entryDate = entryDate.plusDays(1);
            entryTime = dailyStartTime;
        }

        entry.setCalendar(calendar);
    }

    calendar.stopBatchUpdates();

    label.setText("Time: " + (System.currentTimeMillis() - startTime));
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:32,代碼來源:HelloPerformance.java

示例7: intersect

import java.time.LocalTime; //導入方法依賴的package包/類
public static boolean intersect(LocalTime aStart, LocalTime aEnd,
                                LocalTime bStart, LocalTime bEnd) {

    // Same start time or same end time?
    if (aStart.equals(bStart) || aEnd.equals(bEnd)) {
        return true;
    }

    return aStart.isBefore(bEnd) && aEnd.isAfter(bStart);

}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:12,代碼來源:Util.java

示例8: withinTimeSpan

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Method to check whether a give point in time is within a span of time.
 *
 * @param startTime Start of the time span.
 * @param endTime   end of the time span.
 * @param timePoint checks if this time point is within timespan.
 * @return True if the time is within the borders.
 */
public static boolean withinTimeSpan(final LocalTime startTime, final LocalTime endTime, final LocalTime timePoint) {
    if (startTime.isBefore(endTime)) {
        // timespan is wihtin a day
        return (timePoint.isAfter(startTime) || timePoint.equals(startTime))
                && (timePoint.isBefore(endTime) || timePoint.equals(endTime));
    } else {
        // timespan is not within a day (through midnight, e.g.  23:30 - 0:15)
        return (timePoint.isAfter(startTime) || timePoint.equals(startTime))
                || (timePoint.isBefore(endTime) || timePoint.equals(endTime));
    }
}
 
開發者ID:lucasbuschlinger,項目名稱:BachelorPraktikum,代碼行數:20,代碼來源:TimestampUtils.java

示例9: assertTimeNotInNoRaidTimespan

import java.time.LocalTime; //導入方法依賴的package包/類
public static void assertTimeNotInNoRaidTimespan(User user, LocalTime time, LocaleService localeService) {
    if (time.isAfter(LocalTime.of(22, 00)) || time.isBefore(LocalTime.of(6, 0))) {
        throw new UserMessedUpException(user,
                localeService.getMessageFor(LocaleService.NO_RAIDS_NOW, localeService.getLocaleForUser(user),
                        printTime(time)));
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:8,代碼來源:Utils.java

示例10: validate

import java.time.LocalTime; //導入方法依賴的package包/類
@Override
protected boolean validate() {
    LocalDate today = LocalDate.now();
    LocalTime start = startTime.getValue();
    LocalTime end = endTime.getValue();

    if(name.getText().isEmpty()){
        MessageHelper.showErrorAlertMessage("The Name is missing.");
        name.requestFocus();
        return false;
    } else if(date.getValue() == null || date.getValue().isBefore(today) ){
        MessageHelper.showErrorAlertMessage("The date is not valid.");
        date.requestFocus();
        return false;
    } else if(start == null) {
        MessageHelper.showErrorAlertMessage("The starttime is missing.");
        return false;
    } else if(end != null && (start.isAfter(end) || start.equals(end))) {
        MessageHelper.showErrorAlertMessage("The endtime is not after the starttime. ");
        return false;
    } else if(date.getValue().equals(today) && start.isBefore(LocalTime.now())){
        MessageHelper.showErrorAlertMessage("The starttime must be in future.");
        date.requestFocus();
        return false;
    }
    return true;
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:28,代碼來源:EditNonMusicalEventController.java

示例11: validate

import java.time.LocalTime; //導入方法依賴的package包/類
protected boolean validate() {
    LocalDate today = LocalDate.now();
    LocalTime start = startTime.getValue();
    LocalTime end = endTime.getValue();

    if(name.getText().isEmpty()){
        MessageHelper.showErrorAlertMessage("The Name is missing.");
        name.requestFocus();
        return false;
    } else if(date.getValue() == null || date.getValue().isBefore(today) ){
        MessageHelper.showErrorAlertMessage("The date is not valid.");
        date.requestFocus();
        return false;
    } else if(start == null) {
        MessageHelper.showErrorAlertMessage("The starttime is missing.");
        return false;
    } else if(end != null && (start.isAfter(end) || start.equals(end))) {
        MessageHelper.showErrorAlertMessage("The endtime is not after the starttime. ");
        return false;
    } else if(date.getValue().equals(today) && start.isBefore(LocalTime.now())){
        MessageHelper.showErrorAlertMessage("The starttime must be in future.");
        date.requestFocus();
        return false;
    } else if(musicalWorks == null || musicalWorks.isEmpty()){
        MessageHelper.showErrorAlertMessage("A musical work has to be selected.");
        return false;
    }
    return true;
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:30,代碼來源:CreateController.java

示例12: trimTimeBounds

import java.time.LocalTime; //導入方法依賴的package包/類
private void trimTimeBounds() {
    if (this instanceof WeekDayView) {
        return;
    }

    LoggingDomain.PRINTING.fine("trimming hours");

    LocalTime st = LocalTime.of(8, 0);
    LocalTime et = LocalTime.of(19, 0);

    LocalTime etu = getEarliestTimeUsed();
    LocalTime ltu = getLatestTimeUsed();

    LoggingDomain.PRINTING.fine("earliest time: " + etu + ", latest time: " + ltu);

    setEarlyLateHoursStrategy(EarlyLateHoursStrategy.HIDE);

    if (etu != null && ltu != null && ltu.isAfter(etu)) {
        // some padding before the first entry
        if (!etu.isBefore(LocalTime.of(1, 0))) {
            etu = etu.minusHours(1);
        } else {
            etu = LocalTime.MIN;
        }

        // some padding after the last entry
        if (!ltu.isAfter(LocalTime.of(23, 0))) {
            ltu = ltu.plusHours(1);
        } else {
            ltu = LocalTime.MAX;
        }

        // only adjust start time if it is too late
        if (etu.isBefore(st.plusHours(1))) {
            setStartTime(etu);
        } else {
            setStartTime(st);
        }

        // only adjust end time if it is too early
        if (ltu.isAfter(et.minusHours(1))) {
            setEndTime(ltu);
        } else {
            setEndTime(et);
        }
    } else {
        setStartTime(st);
        setEndTime(et);
    }

    setVisibleHours(Math.min(24, (int) getStartTime().until(getEndTime(), ChronoUnit.HOURS)));
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:53,代碼來源:DayViewBase.java

示例13: layoutChildren

import java.time.LocalTime; //導入方法依賴的package包/類
@Override
protected void layoutChildren(double contentX, double contentY,
                              double contentWidth, double contentHeight) {
    super.layoutChildren(contentX, contentY, contentWidth, contentHeight);

    int labelCount = labels.size();

    // now label
    LocalTime now = getSkinnable().getTime();
    currentTimeLabel.setText(now.format(formatter));
    placeLabel(currentTimeLabel, now, contentX, contentY, contentWidth,
            contentHeight);

    // hour labels
    LocalTime startTime = getSkinnable().getStartTime();
    LocalTime endTime = getSkinnable().getEndTime();

    for (int hour = 0; hour < labelCount; hour++) {
        LocalTime time = LocalTime.of(hour + 1, 0);
        Label label = labels.get(hour);

        label.getStyleClass().removeAll("early-hour-label", //$NON-NLS-1$
                "late-hour-label"); //$NON-NLS-1$

        placeLabel(label, time, contentX, contentY, contentWidth,
                contentHeight);

        Bounds localToParent1 = currentTimeLabel
                .localToParent(currentTimeLabel.getLayoutBounds());
        Bounds localToParent2 = label
                .localToParent(label.getLayoutBounds());

        if (currentTimeLabel.isVisible()
                && getSkinnable().isShowCurrentTimeMarker()
                && localToParent1.intersects(localToParent2)) {
            label.setVisible(false);
        } else {
            label.setVisible(true);
        }

        if (time.isBefore(startTime)) {
            if (!label.getStyleClass().contains("early-hour-label")) { //$NON-NLS-1$
                label.getStyleClass().add("early-hour-label"); //$NON-NLS-1$
            }
        }
        if (time.isAfter(endTime)) {
            if (!label.getStyleClass().contains("late-hour-label")) { //$NON-NLS-1$
                label.getStyleClass().add("late-hour-label"); //$NON-NLS-1$
            }
        }

        if (label.isVisible()) {
            switch (getSkinnable().getEarlyLateHoursStrategy()) {
                case HIDE:
                case SHOW_COMPRESSED:
                    if (time.isBefore(startTime) || time.isAfter(endTime)) {
                        label.setVisible(false);
                    }
                    break;
                case SHOW:
                    label.setVisible(true);
                    break;
                default:
                    break;

            }
        }
    }

    currentTimeLabel.toFront();
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:72,代碼來源:TimeScaleViewSkin.java

示例14: updateLineStyling

import java.time.LocalTime; //導入方法依賴的package包/類
private void updateLineStyling() {
    T dayView = getSkinnable();

    LocalTime startTime = dayView.getStartTime();
    LocalTime endTime = dayView.getEndTime();

    boolean showEarlyHoursRegion = startTime.isAfter(LocalTime.MIN);
    boolean showLateHoursRegion = endTime.isBefore(LocalTime.MAX);

    earlyHoursRegion.setVisible(showEarlyHoursRegion);
    lateHoursRegion.setVisible(showLateHoursRegion);

    int lineCount = lines.size();

    for (int i = 0; i < lineCount; i++) {
        Line line = lines.get(i);

        line.getStyleClass().removeAll("early-hour-line", "late-hour-line"); //$NON-NLS-1$ //$NON-NLS-2$

        int hour = (i + 1) / 2;
        int minute = 0;

        boolean halfHourLine = (i % 2 == 0);
        if (halfHourLine) {
            minute = 30;
        }

        LocalTime time = LocalTime.of(hour, minute);

        if (time.isBefore(startTime)) {
            if (!line.getStyleClass().contains("early-hour-line")) { //$NON-NLS-1$
                line.getStyleClass().add("early-hour-line"); //$NON-NLS-1$
            }
        }
        if (time.isAfter(endTime)) {
            if (!line.getStyleClass().contains("late-hour-line")) { //$NON-NLS-1$
                line.getStyleClass().add("late-hour-line"); //$NON-NLS-1$
            }
        }

        switch (dayView.getEarlyLateHoursStrategy()) {
            case HIDE:
                /*
                 * We do not show ... a) lines before the start time and after
                 * the end time b) lines directly on the start time or end time
                 * because they make the UI look messy
                 */
                if (time.isBefore(startTime) || time.equals(startTime) || time.isAfter(endTime) || time.equals(endTime)) {
                    line.setVisible(false);
                } else {
                    line.setVisible(true);
                }
                break;
            case SHOW:
                line.setVisible(true);
                break;
            case SHOW_COMPRESSED:
                if (halfHourLine) {
                    line.setVisible(false);
                } else {
                    line.setVisible(true);
                }
                break;
            default:
                break;

        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:70,代碼來源:DayViewSkin.java

示例15: getTimeLocation

import java.time.LocalTime; //導入方法依賴的package包/類
public static double getTimeLocation(DayViewBase view, LocalTime time, boolean prefHeight) {
    LocalTime startTime = view.getStartTime();
    LocalTime endTime = view.getEndTime();
    double availableHeight = view.getHeight();
    if (prefHeight) {
        availableHeight = view.prefHeight(-1);
    }
    EarlyLateHoursStrategy strategy = view.getEarlyLateHoursStrategy();

    switch (strategy) {
        case SHOW:
            long startNano = LocalTime.MIN.toNanoOfDay();
            long endNano = LocalTime.MAX.toNanoOfDay();

            double npp = (endNano - startNano) / availableHeight;

            return ((int) ((time.toNanoOfDay() - startNano) / npp)) + .5;
        case HIDE:
            if (time.isBefore(startTime)) {
                return -1;
            }

            if (time.isAfter(endTime)) {
                return availableHeight;
            }

            startNano = startTime.toNanoOfDay();
            endNano = endTime.toNanoOfDay();

            npp = (endNano - startNano) / availableHeight;

            return ((int) ((time.toNanoOfDay() - startNano) / npp)) + .5;
        case SHOW_COMPRESSED:
            long earlyHours = ChronoUnit.HOURS
                    .between(LocalTime.MIN, startTime);
            long lateHours = ChronoUnit.HOURS.between(endTime, LocalTime.MAX) + 1;
            double hourHeightCompressed = view.getHourHeightCompressed();
            double earlyHeight = hourHeightCompressed * earlyHours;
            double lateHeight = hourHeightCompressed * lateHours;

            if (time.isBefore(startTime)) {
                /*
                 * Early compressed hours.
                 */
                startNano = LocalTime.MIN.toNanoOfDay();
                endNano = startTime.toNanoOfDay();

                npp = (endNano - startNano) / earlyHeight;

                return ((int) ((time.toNanoOfDay() - startNano) / npp)) + .5;
            } else if (time.isAfter(endTime)) {
                /*
                 * Late compressed hours.
                 */
                startNano = endTime.toNanoOfDay();
                endNano = LocalTime.MAX.toNanoOfDay();

                npp = (endNano - startNano) / lateHeight;

                return ((int) ((time.toNanoOfDay() - startNano) / npp))
                        + (availableHeight - lateHeight) + .5;
            } else {
                /*
                 * Regular hours.
                 */
                startNano = startTime.toNanoOfDay();
                endNano = endTime.toNanoOfDay();
                npp = (endNano - startNano)
                        / (availableHeight - earlyHeight - lateHeight);

                return earlyHeight
                        + ((int) ((time.toNanoOfDay() - startNano) / npp)) + .5;
            }
        default:
            return 0;
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:78,代碼來源:ViewHelper.java


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