@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); }
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);
ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone); ZonedDateTime zonedNextTarget = zonedNow.withHour(targetHour).withMinute(targetMin).withSecond(targetSec); if(zonedNow.compareTo(zonedNextTarget) > 0) zonedNextTarget = zonedNextTarget.plusDays(1);
if (notValidBefore.compareTo(notValidAfter) > 0) { throw log.validAfterBeforeValidBefore(notValidBefore, notValidAfter);
@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; }
/** * <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())); }
@Override public int compare(Object o1, Object o2) { return ((ZonedDateTime) o1).compareTo((ZonedDateTime) o2); } }
/** * 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; }
@Override public int compareTo(Notification that) { int diff = this.createdAt.compareTo(that.createdAt); if (diff != 0) return diff; return this.notificationId.compareTo(that.notificationId); }
@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; }
@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; }
@Override public int compare(ReflogEntry arg0, ReflogEntry arg1) { return HGit.getTime(arg1).compareTo(HGit.getTime(arg0)); } }
@Override public int compareTo(DateHour other) { return dateTime().compareTo(other.dateTime()); } }
private int compare(ZonedDateTime first, ZonedDateTime second) { return first.withZoneSameInstant(DateTimeUtil.UTC).compareTo(second.withZoneSameInstant(DateTimeUtil.UTC)); } }
/** * 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()); }
@Override public int compareTo(Metadata that) { int diff = this.getCreatedAt().compareTo(that.getCreatedAt()); if (diff != 0) return diff; return this.getGuid().compareTo(that.getGuid()); } }
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)); }
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)); }