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