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


Java LocalTime.isBefore方法代码示例

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


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

示例1: main

import java.time.LocalTime; //导入方法依赖的package包/类
public static void main(String[] args) {
    LocalTime time = LocalTime.of(16, 20, 12, 98547);
    System.out.println(time.getHour());
    System.out.println(time.getMinute());
    System.out.println(time.getSecond());
    System.out.println(time.getNano());

    LocalTime shreyaFinishTime = LocalTime.parse("17:09:04");
    LocalTime paulFinishTime = LocalTime.parse("17:09:12");
    if (shreyaFinishTime.isBefore(paulFinishTime)) {
        System.out.println("Shreya wins");
    } else {
        System.out.println("Paul wins");
    }

}
 
开发者ID:huby,项目名称:java-se8-oca-study-guide,代码行数:17,代码来源:Main.java

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

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

示例4: testRangeOfLocalTimes

import java.time.LocalTime; //导入方法依赖的package包/类
@Test(dataProvider = "localTimeRanges")
public void testRangeOfLocalTimes(LocalTime start, LocalTime end, Duration step, boolean parallel) {
    final Range<LocalTime> range = Range.of(start, end, step);
    final Array<LocalTime> array = range.toArray(parallel);
    final boolean ascend = start.isBefore(end);
    final int expectedLength = (int)Math.ceil(Math.abs((double)ChronoUnit.SECONDS.between(start, end)) / (double)step.getSeconds());
    Assert.assertEquals(array.length(), expectedLength);
    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");
    LocalTime expected = null;
    for (int i=0; i<array.length(); ++i) {
        final LocalTime actual = array.getValue(i);
        expected = expected == null ? start : ascend ? expected.plus(step) : expected.minus(step);
        Assert.assertEquals(actual, expected, "Value matches at " + i);
        Assert.assertTrue(ascend ? actual.compareTo(start) >=0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + i);
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:20,代码来源:RangeBasicTests.java

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

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

示例7: buildRecord

import java.time.LocalTime; //导入方法依赖的package包/类
private HttrackRecord buildRecord(LocalTime time, String url, String rawfile, String mime,
                                  String referrer) throws IOException {
    if (previousTime != null && time.isBefore(previousTime)) {
        // if we go backwards in time, assume we've wrapped around to the next day
        date = date.plusDays(1);
    }
    LocalDateTime timestamp = time.atDate(date);
    previousTime = time;

    if (!rawfile.startsWith(outputDir)) {
        throw new ParsingException("new.txt localfile (" + rawfile + ") outside output dir (" + outputDir + ")");
    }

    rawfile = rawfile.substring(outputDir.length());

    CacheEntry cacheEntry = cache.getEntry(url);
    if (cacheEntry == null) {
        throw new IOException("no cache entry: " + url);
    }

    String filename = percentDecode(rawfile);
    Path file = dir.resolve(filename);
    if (!file.toAbsolutePath().startsWith(dir.toAbsolutePath())) {
        throw new IOException(file + " is outside of " + dir);
    }

    String fixedUrl = HtsUtil.fixupUrl(url);
    return new HttrackRecord(
            filename,
            timestamp,
            fixedUrl,
            mime,
            requestHeaders.get(fixedUrl),
            responseHeaders.get(fixedUrl),
            referrer,
            file,
            cacheEntry);
}
 
开发者ID:nla,项目名称:httrack2warc,代码行数:39,代码来源:HttrackCrawl.java

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

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

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

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

示例12: 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,代码来源:EditRehearsalController.java

示例13: createControl

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
protected DateControl createControl() {
    CalendarSource source = new CalendarSource();
    source.setName("Demo Source");

    Calendar[] calendar = new Calendar[7];
    for (int i = 0; i < 7; i++) {
        calendar[i] = new Calendar("Calendar " + i);
        calendar[i].setStyle(Calendar.Style.getStyle(i));
    }

    for (int i = 0; i < 1000; i++) {
        Entry<String> entry = new Entry<>("Entry " + i);
        LocalDate date = LocalDate.now();
        if (Math.random() < .5) {
            date = date.minusDays((long) (Math.random() * 365));
        } else {
            date = date.plusDays((long) (Math.random() * 365));
        }

        LocalTime start = LocalTime.of((int) (Math.random() * 20), (int) (Math.random() * 30));
        Duration duration = Duration.ofHours((int) (Math.random() * 8));
        LocalTime end = start.plus(duration);
        if (end.isBefore(start)) {
            end = LocalTime.MAX;
        }

        entry.changeStartDate(date);
        entry.changeEndDate(date);
        entry.changeStartTime(start);
        entry.changeEndTime(end);

        if (Math.random() > .9) {
            entry.setFullDay(true);
        }

        entry.setCalendar(calendar[(int) (Math.random() * 7)]);
    }

    source.getCalendars().addAll(calendar);

    monthView = new MonthSheetView();
    monthView.getCalendarSources().add(source);
    monthView.setCellFactory(param -> new MonthSheetView.DetailedDateCell(param.getView(), param.getDate()));

    return monthView;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:48,代码来源:HelloMonthSheetView.java

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

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


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