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