java.time.ZonedDateTime.compareTo()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中java.time.ZonedDateTime.compareTo()方法的一些代码示例,展示了ZonedDateTime.compareTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.compareTo()方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:compareTo

ZonedDateTime.compareTo介绍

暂无

代码示例

代码示例来源:origin: chewiebug/GCViewer

@Override
public int compareTo(Timestamp o) {
  if(o instanceof GcDateStamp)
    return this.time.compareTo(((GcDateStamp)o).time);
  throw new IllegalArgumentException("Can't compare Datestamp with Timestamp: " +o);
}

代码示例来源:origin: stackoverflow.com

LocalDateTime localNow = LocalDateTime.now();
   ZoneId currentZone = ZoneId.of("America/Los_Angeles");
   ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone);
   ZonedDateTime zonedNext5 ;
   zonedNext5 = zonedNow.withHour(5).withMinute(0).withSecond(0);
   if(zonedNow.compareTo(zonedNext5) > 0)
     zonedNext5 = zonedNext5.plusDays(1);
   Duration duration = Duration.between(zonedNow, zonedNext5);
   long initalDelay = duration.getSeconds();
   ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);            
   scheduler.scheduleAtFixedRate(new MyRunnableTask(), initalDelay,
                  24*60*60, TimeUnit.SECONDS);

代码示例来源:origin: stackoverflow.com

ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone);
ZonedDateTime zonedNextTarget = zonedNow.withHour(targetHour).withMinute(targetMin).withSecond(targetSec);
if(zonedNow.compareTo(zonedNextTarget) > 0)
  zonedNextTarget = zonedNextTarget.plusDays(1);

代码示例来源:origin: wildfly/wildfly

if (notValidBefore.compareTo(notValidAfter) > 0) {
  throw log.validAfterBeforeValidBefore(notValidBefore, notValidAfter);

代码示例来源:origin: eclipse/smarthome

@Override
public boolean equals(@Nullable Object obj) {
  if (this == obj) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  DateTimeType other = (DateTimeType) obj;
  if (zonedDateTime == null) {
    if (other.zonedDateTime != null) {
      return false;
    }
  } else if (zonedDateTime.compareTo(other.zonedDateTime) != 0) {
    return false;
  }
  return true;
}

代码示例来源:origin: pholser/junit-quickcheck

/**
 * <p>Tells this generator to produce values within a specified
 * {@linkplain InRange#min() minimum} and/or {@linkplain InRange#max()
 * maximum}, inclusive, with uniform distribution, down to the
 * nanosecond.</p>
 *
 * <p>If an endpoint of the range is not specified, the generator will use
 * dates with values of either {@link java.time.Instant#MIN} or
 * {@link java.time.Instant#MAX} and UTC zone as appropriate.</p>
 *
 * <p>{@link InRange#format()} describes
 * {@linkplain DateTimeFormatter#ofPattern(String) how the generator is to
 * interpret the range's endpoints}.</p>
 *
 * @param range annotation that gives the range's constraints
 */
public void configure(InRange range) {
  DateTimeFormatter formatter = DateTimeFormatter.ofPattern(range.format());
  if (!defaultValueOf(InRange.class, "min").equals(range.min())) {
    min = ZonedDateTime.parse(range.min(), formatter)
      .withZoneSameInstant(UTC_ZONE_ID);
  }
  if (!defaultValueOf(InRange.class, "max").equals(range.max())) {
    max = ZonedDateTime.parse(range.max(), formatter)
      .withZoneSameInstant(UTC_ZONE_ID);
  }
  if (min.compareTo(max) > 0)
    throw new IllegalArgumentException(String.format("bad range, %s > %s", range.min(), range.max()));
}

代码示例来源:origin: com.sqlapp/sqlapp-core

@Override
public boolean hasNext() {
  if (this.step>0){
    return (next.compareTo(end)<0);
  } else{
    return (next.compareTo(end)>0);
  }
}

代码示例来源:origin: org.jadira.usertype/usertype.extended

@Override
  public int compare(Object o1, Object o2) {
    return ((ZonedDateTime) o1).compareTo((ZonedDateTime) o2);
  }
}

代码示例来源:origin: zavtech/morpheus-core

/**
 * 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;
}

代码示例来源:origin: org.tiogasolutions.notify/tioga-notify-pub

@Override
public int compareTo(Notification that) {
  int diff = this.createdAt.compareTo(that.createdAt);
  if (diff != 0) return diff;
  return this.notificationId.compareTo(that.notificationId);
}

代码示例来源:origin: com.sqlapp/sqlapp-core

@Override
public boolean hasNext() {
  if (this.step.isPositive()){
    return (next.compareTo(end)<0);
  } else{
    return (next.compareTo(end)>0);
  }
}

代码示例来源:origin: org.tiogasolutions.apis/tioga-apis-cloudfoundry

@Override
public int compareTo(Event that) {
 int diff = this.timestamp.compareTo(that.timestamp);
 if (diff != 0) return diff;
 diff = this.type.compareTo(that.type);
 if (diff != 0) return diff;
 diff = this.actee.compareTo(that.actee);
 if (diff != 0) return diff;
 diff = this.actor.compareTo(that.actor);
 return diff;
}

代码示例来源:origin: org.ogema.eval/timeseries-aggregation

@Override
public SampledValue next() {
  if (next == null)
    throw new NoSuchElementException();
  final SampledValue current = getValue(next);
  next = next.plus(duration, unit);
  if (next.compareTo(endTime) > 0) 
    next = null;
  return current;
}

代码示例来源:origin: com.g2forge.gearbox/gb-git

@Override
  public int compare(ReflogEntry arg0, ReflogEntry arg1) {
    return HGit.getTime(arg1).compareTo(HGit.getTime(arg0));
  }
}

代码示例来源:origin: spotify/flo

@Override
 public int compareTo(DateHour other) {
  return dateTime().compareTo(other.dateTime());
 }
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

private int compare(ZonedDateTime first, ZonedDateTime second) {
    return first.withZoneSameInstant(DateTimeUtil.UTC).compareTo(second.withZoneSameInstant(DateTimeUtil.UTC));
  }
}

代码示例来源:origin: zavtech/morpheus-core

/**
 * 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());
}

代码示例来源:origin: org.tiogasolutions.apis/tioga-apis-cloudfoundry

@Override
 public int compareTo(Metadata that) {
  int diff = this.getCreatedAt().compareTo(that.getCreatedAt());
  if (diff != 0) return diff;

  return this.getGuid().compareTo(that.getGuid());
 }
}

代码示例来源:origin: com.twosigma.webtau/webtau-core

private void compareZonedDateTimes(ZonedDateTime actual, ZonedDateTime expected) {
  ZonedDateTime normalizedActual = actual.withZoneSameInstant(UTC);
  ZonedDateTime normalizedExpected = expected.withZoneSameInstant(UTC);
  report(normalizedActual.compareTo(normalizedExpected), renderActualExpectedWithNormalized(actual, expected,
      normalizedActual, normalizedExpected));
}

代码示例来源:origin: twosigma/webtau

private void compareZonedDateTimes(ZonedDateTime actual, ZonedDateTime expected) {
  ZonedDateTime normalizedActual = actual.withZoneSameInstant(UTC);
  ZonedDateTime normalizedExpected = expected.withZoneSameInstant(UTC);
  report(normalizedActual.compareTo(normalizedExpected), renderActualExpectedWithNormalized(actual, expected,
      normalizedActual, normalizedExpected));
}

相关文章

ZonedDateTime类方法