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