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


Java LocalTime.equals方法代碼示例

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


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

示例1: of

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Obtains an instance defining the yearly rule to create transitions between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param month  the month of the month-day of the first day of the cutover week, not null
 * @param dayOfMonthIndicator  the day of the month-day of the cutover week, positive if the week is that
 *  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 *  from -28 to 31 excluding 0
 * @param dayOfWeek  the required day-of-week, null if the month-day should not be changed
 * @param time  the cutover time in the 'before' offset, not null
 * @param timeEndOfDay  whether the time is midnight at the end of day
 * @param timeDefnition  how to interpret the cutover
 * @param standardOffset  the standard offset in force at the cutover, not null
 * @param offsetBefore  the offset before the cutover, not null
 * @param offsetAfter  the offset after the cutover, not null
 * @return the rule, not null
 * @throws IllegalArgumentException if the day of month indicator is invalid
 * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
 */
public static ZoneOffsetTransitionRule of(
        Month month,
        int dayOfMonthIndicator,
        DayOfWeek dayOfWeek,
        LocalTime time,
        boolean timeEndOfDay,
        TimeDefinition timeDefnition,
        ZoneOffset standardOffset,
        ZoneOffset offsetBefore,
        ZoneOffset offsetAfter) {
    Objects.requireNonNull(month, "month");
    Objects.requireNonNull(time, "time");
    Objects.requireNonNull(timeDefnition, "timeDefnition");
    Objects.requireNonNull(standardOffset, "standardOffset");
    Objects.requireNonNull(offsetBefore, "offsetBefore");
    Objects.requireNonNull(offsetAfter, "offsetAfter");
    if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
        throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
    }
    if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
        throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
    }
    return new ZoneOffsetTransitionRule(month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefnition, standardOffset, offsetBefore, offsetAfter);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:46,代碼來源:ZoneOffsetTransitionRule.java

示例2: test_plusMinutes_fromZero

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_plusMinutes_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(1);
    LocalTime t = LocalTime.of(22, 49);

    for (int i = -70; i < 70; i++) {
        LocalDateTime dt = base.plusMinutes(i);
        t = t.plusMinutes(1);

        if (t.equals(LocalTime.MIDNIGHT)) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d, String.valueOf(i));
        assertEquals(dt.toLocalTime(), t, String.valueOf(i));
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:TCKLocalDateTime.java

示例3: test_minusMinutes_fromZero

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_minusMinutes_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(1);
    LocalTime t = LocalTime.of(22, 49);

    for (int i = 70; i > -70; i--) {
        LocalDateTime dt = base.minusMinutes(i);
        t = t.plusMinutes(1);

        if (t.equals(LocalTime.MIDNIGHT)) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:TCKLocalDateTime.java

示例4: 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,代碼來源:CreateNonMusicalEventController.java

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

示例6: 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,代碼來源:EditController.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: now_ZoneId

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    LocalTime expected = LocalTime.now(Clock.system(zone));
    LocalTime test = LocalTime.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = LocalTime.now(Clock.system(zone));
        test = LocalTime.now(zone);
    }
    assertEquals(test, expected);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:TCKLocalTime.java

示例9: of

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Obtains an instance defining the yearly rule to create transitions between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param month  the month of the month-day of the first day of the cutover week, not null
 * @param dayOfMonthIndicator  the day of the month-day of the cutover week, positive if the week is that
 *  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 *  from -28 to 31 excluding 0
 * @param dayOfWeek  the required day-of-week, null if the month-day should not be changed
 * @param time  the cutover time in the 'before' offset, not null
 * @param timeEndOfDay  whether the time is midnight at the end of day
 * @param timeDefnition  how to interpret the cutover
 * @param standardOffset  the standard offset in force at the cutover, not null
 * @param offsetBefore  the offset before the cutover, not null
 * @param offsetAfter  the offset after the cutover, not null
 * @return the rule, not null
 * @throws IllegalArgumentException if the day of month indicator is invalid
 * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
 * @throws IllegalArgumentException if {@code time.getNano()} returns non-zero value
 */
public static ZoneOffsetTransitionRule of(
        Month month,
        int dayOfMonthIndicator,
        DayOfWeek dayOfWeek,
        LocalTime time,
        boolean timeEndOfDay,
        TimeDefinition timeDefnition,
        ZoneOffset standardOffset,
        ZoneOffset offsetBefore,
        ZoneOffset offsetAfter) {
    Objects.requireNonNull(month, "month");
    Objects.requireNonNull(time, "time");
    Objects.requireNonNull(timeDefnition, "timeDefnition");
    Objects.requireNonNull(standardOffset, "standardOffset");
    Objects.requireNonNull(offsetBefore, "offsetBefore");
    Objects.requireNonNull(offsetAfter, "offsetAfter");
    if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
        throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
    }
    if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
        throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
    }
    if (time.getNano() != 0) {
        throw new IllegalArgumentException("Time's nano-of-second must be zero");
    }
    return new ZoneOffsetTransitionRule(month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefnition, standardOffset, offsetBefore, offsetAfter);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:50,代碼來源:ZoneOffsetTransitionRule.java

示例10: now_ZoneId

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    LocalTime expected = LocalTime.now(Clock.system(zone));
    LocalTime test = LocalTime.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = LocalTime.now(Clock.system(zone));
        test = LocalTime.now(zone);
    }
    assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
                 expected.truncatedTo(ChronoUnit.SECONDS));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:TCKLocalTime.java

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

示例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,代碼來源:EditNonMusicalEventController.java

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