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


Java ZonedDateTime.compareTo方法代碼示例

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


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

示例1: initNextTime

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private ZonedDateTime initNextTime(ZonedDateTime start, ZonedDateTime now, Period p, Duration d) {
	// if the start time is in the future next will just be start
	ZonedDateTime next = start;
	// if the start time is in the past, increment until we find the next time to execute
	// cannot call isComplete() here as it depends on nextTime
	if(startTime.compareTo(now) <= 0 && !schedule.getRunOnce()) {
		// TODO: Look to optimize.  Consider a one-second timer, it would take too long
		// For example if only a single unit, e.g. only minutes, then can optimize relative to start 
		// if there are more than one unit, then the loop may be best as it will be difficult
		while(next.compareTo(now) <= 0) {
			next = next.plus(p);
			next = next.plus(d);
		}
	}
	return next;
}
 
開發者ID:edgexfoundry,項目名稱:device-modbus,代碼行數:17,代碼來源:ScheduleContext.java

示例2: initNextTime

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private ZonedDateTime initNextTime(ZonedDateTime start, ZonedDateTime now, Period p, Duration d) {
  // if the start time is in the future next will just be start
  ZonedDateTime next = start;
  // if the start time is in the past, increment until we find the next time to execute
  // cannot call isComplete() here as it depends on nextTime
  if (startTime.compareTo(now) <= 0 && !schedule.getRunOnce()) {
    // TODO: Look to optimize. Consider a one-second timer, it would take too long
    // For example if only a single unit, e.g. only minutes, then can optimize relative to start
    // if there are more than one unit, then the loop may be best as it will be difficult
    while (next.compareTo(now) <= 0) {
      next = next.plus(p);
      next = next.plus(d);
    }
  }

  return next;
}
 
開發者ID:mgjeong,項目名稱:device-opcua-java,代碼行數:18,代碼來源:ScheduleContext.java

示例3: initNextTime

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private ZonedDateTime initNextTime(ZonedDateTime start, ZonedDateTime now, Period p, Duration d) {
  // if the start time is in the future next will just be start
  ZonedDateTime next = start;
  // if the start time is in the past, increment until we find the next time to execute
  // cannot call isComplete() here as it depends on nextTime
  if (startTime.compareTo(now) <= 0 && !schedule.getRunOnce()) {
    // TODO: Look to optimize.  Consider a one-second timer, it would take too long
    // For example if only a single unit, e.g. only minutes, then can optimize relative to start 
    // if there are more than one unit, then the loop may be best as it will be difficult
    while (next.compareTo(now) <= 0) {
      next = next.plus(p);
      next = next.plus(d);
    }
  }

  return next;
}
 
開發者ID:edgexfoundry,項目名稱:device-bluetooth,代碼行數:18,代碼來源:ScheduleContext.java

示例4: getDelayBeforeNextPost

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public static long getDelayBeforeNextPost() {
	ZonedDateTime zonedNow = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault());
	ZonedDateTime zonedNext = zonedNow.withHour(Config.POST_HOUR).withMinute(0).withSecond(0);
	if(zonedNow.compareTo(zonedNext) > 0) {
		zonedNext = zonedNext.plusDays(1);
	}

	return zonedNext.toInstant().toEpochMilli() - zonedNow.toInstant().toEpochMilli();
}
 
開發者ID:Shadorc,項目名稱:1Day1Wallpaper,代碼行數:10,代碼來源:Utils.java

示例5: TimeComparison

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private TimeComparison(
  @Nullable final ZonedDateTime left,
  @Nullable final ZonedDateTime right){

    comparison = left == null || right == null ?
      null :
      left.compareTo(right);

}
 
開發者ID:Xitikit,項目名稱:xitikit-blue,代碼行數:10,代碼來源:TimeComparison.java

示例6: applyThreshold

import java.time.ZonedDateTime; //導入方法依賴的package包/類
/**
 * Check for the input points, compare each with threshold, if it continue
 *   to pass the threshold for the critical/warn/info duration time period, change
 *   its the value to be critical/warn/info, otherwise, it's ok
 */
List<Transmutation> applyThreshold(List<Transmutation> points) {
    // nothing to do
    if (points.isEmpty()) {
        return null;
    }

    Transmutation lastPoint = Iterables.getLast(points);
    ZonedDateTime lastPointTS = lastPoint.time();

    // get the timestamp for the critical, warning, info durations
    //   if the millisecond unit is not supported, it will throw UnsupportedTemporalTypeException
    ZonedDateTime infoDurationTS = lastPointTS.minus(infoDurationMillis(), ChronoUnit.MILLIS);
    ZonedDateTime warnDurationTS = lastPointTS.minus(warnDurationMillis(), ChronoUnit.MILLIS);
    ZonedDateTime criticalDurationTS = lastPointTS.minus(criticalDurationMillis(), ChronoUnit.MILLIS);

    ListIterator<Transmutation> iter = points.listIterator(points.size());
    boolean matchThreshold = true;
    boolean atWarningLevel = false;
    boolean atInfoLevel = false;

    while (iter.hasPrevious() && matchThreshold) {
        Transmutation result = iter.previous();
        ZonedDateTime pointTS = result.time();

        Number value = result.value();
        matchThreshold = type().matches(value, threshold());

        if (matchThreshold) {
            if (pointTS.compareTo(criticalDurationTS) <= 0) {
                return Collections.singletonList(appendMessage(changeValue(result, CRIT.value()), CRIT.code(), threshold(), criticalDurationMillis()));

            } else if (pointTS.compareTo(warnDurationTS) <= 0) {
                atWarningLevel = true;

            } else if (pointTS.compareTo(infoDurationTS) <= 0) {
                atInfoLevel = true;
            }

        } else {
            if (pointTS.compareTo(warnDurationTS) <= 0) {
                return Collections.singletonList(appendMessage(changeValue(result, WARN.value()), WARN.code(), threshold(), warnDurationMillis()));

            } else if (pointTS.compareTo(infoDurationTS) <= 0) {
                return Collections.singletonList(appendMessage(changeValue(result, INFO.value()), INFO.code(), threshold(), warnDurationMillis()));

            } else {
                return Collections.singletonList(changeValue(result, OK.value())); // OK status
            }
        }
    }

    // critical, warning or info duration value is longer than available input time series
    return atWarningLevel
            ? Collections.singletonList(appendMessage(changeValue(lastPoint, WARN.value()), WARN.code(), threshold(), warnDurationMillis()))
            : (atInfoLevel
                    ? Collections.singletonList(appendMessage(changeValue(lastPoint, INFO.value()), INFO.code(), threshold(), warnDurationMillis()))
                    : Collections.singletonList(changeValue(lastPoint, OK.value())));
}
 
開發者ID:salesforce,項目名稱:pyplyn,代碼行數:64,代碼來源:ThresholdMetForDuration.java

示例7: test_compareTo_null

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void test_compareTo_null() {
    ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100);
    a.compareTo(null);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKZonedDateTime.java

示例8: inRange

import java.time.ZonedDateTime; //導入方法依賴的package包/類
/**
 * Is a date in the date range
 *
 * @param date
 *            The date to check
 * @return true if the date range contains a date start and end of range
 *         inclusive; false otherwise
 */
public boolean inRange(ZonedDateTime date) {
    if (date == null) {
        return false;
    }

    return date.compareTo(start) >= 0 && date.compareTo(end) <= 0;
}
 
開發者ID:blackbluegl,項目名稱:calendar-component,代碼行數:16,代碼來源:CalendarDateRange.java

示例9: RangeOfZonedDateTimes

import java.time.ZonedDateTime; //導入方法依賴的package包/類
/**
 * Constructor
 * @param start     the start for range, inclusive
 * @param end       the end for range, exclusive
 * @param step      the step increment
 * @param excludes  optional predicate to exclude elements in this range
 */
RangeOfZonedDateTimes(ZonedDateTime start, ZonedDateTime end, Duration step, Predicate<ZonedDateTime> excludes) {
    super(start, end);
    this.step = step;
    this.ascend = start.compareTo(end) <= 0;
    this.excludes = excludes;
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:14,代碼來源:RangeOfZonedDateTimes.java

示例10: inBounds

import java.time.ZonedDateTime; //導入方法依賴的package包/類
/**
 * Checks that the value specified is in the bounds of this range
 * @param value     the value to check if in bounds
 * @return          true if in bounds
 */
private boolean inBounds(ZonedDateTime value) {
    return ascend ? value.compareTo(start()) >=0 && value.isBefore(end()) : value.compareTo(start()) <=0 && value.isAfter(end());
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:9,代碼來源:RangeOfZonedDateTimes.java


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