/** * 直接向服务查询, 不再自作聪明地在本地进行过期时间检查, 以免无法区分not found与conflict */ @Deprecated private void checkExpireInLocal(TccRequest request, List<Participant> participantLinks) { // 获取最接近过期的时间 final OffsetDateTime theClosestToExpire = fetchTheRecentlyExpireTime(participantLinks); if (theClosestToExpire.minusSeconds(LEEWAY).isBefore(OffsetDateTime.now())) { // 释放全部资源 cancel(request); throw new ReservationAlmostToExpireException("there are resources be about to expire at " + theClosestToExpire); } }
/** * Verifies that the actual {@code OffsetDateTime} is after or equals to the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z")) * .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));</code></pre> * * @param other the given {@link java.time.OffsetDateTime}. * @return this assertion object. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}. * @throws AssertionError if the actual {@code OffsetDateTime} is not after or equals to the given one. */ public SELF isAfterOrEqualTo(OffsetDateTime other) { Objects.instance().assertNotNull(info, actual); assertOffsetDateTimeParameterIsNotNull(other); if (actual.isBefore(other)) { throw Failures.instance().failure(info, shouldBeAfterOrEqualsTo(actual, other)); } return myself; }
/** * Verifies that the actual {@code OffsetDateTime} is <b>strictly</b> before the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));</code></pre> * * @param other the given {@link java.time.OffsetDateTime}. * @return this assertion object. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}. * @throws AssertionError if the actual {@code OffsetDateTime} is not strictly before the given one. */ public SELF isBefore(OffsetDateTime other) { Objects.instance().assertNotNull(info, actual); assertOffsetDateTimeParameterIsNotNull(other); if (!actual.isBefore(other)) { throw Failures.instance().failure(info, shouldBeBefore(actual, other)); } return myself; }
/** * Verifies that the actual {@code OffsetDateTime} is <b>strictly</b> before the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));</code></pre> * * @param other the given {@link java.time.OffsetDateTime}. * @return this assertion object. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}. * @throws AssertionError if the actual {@code OffsetDateTime} is not strictly before the given one. */ public SELF isBefore(OffsetDateTime other) { Objects.instance().assertNotNull(info, actual); assertOffsetDateTimeParameterIsNotNull(other); if (!actual.isBefore(other)) { throw Failures.instance().failure(info, shouldBeBefore(actual, other)); } return myself; }
/** * Verifies that the actual {@code OffsetDateTime} is after or equals to the given one. * <p> * Example : * <pre><code class='java'> assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z")) * .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));</code></pre> * * @param other the given {@link java.time.OffsetDateTime}. * @return this assertion object. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}. * @throws AssertionError if the actual {@code OffsetDateTime} is not after or equals to the given one. */ public SELF isAfterOrEqualTo(OffsetDateTime other) { Objects.instance().assertNotNull(info, actual); assertOffsetDateTimeParameterIsNotNull(other); if (actual.isBefore(other)) { throw Failures.instance().failure(info, shouldBeAfterOrEqualsTo(actual, other)); } return myself; }
public boolean isBlockingExpired() { return Optional.ofNullable(blockingExpirationTimestamp) .map(timestamp -> timestamp.isBefore(OffsetDateTime.now())) .orElse(false); } }
public boolean isBlockingExpired() { return Optional.ofNullable(blockingExpirationTimestamp) .map(timestamp -> timestamp.isBefore(OffsetDateTime.now())) .orElse(false); } }
public static TimeInterval ofStartDateTimeAndEndDateTime(OffsetDateTime startDateTime, OffsetDateTime endDateTime) { checkNotNull(startDateTime, "A start date time hasn't been specified."); checkNotNull(endDateTime, "An end date time hasn't been specified."); checkArgument(!endDateTime.isBefore(startDateTime), "The specified start and end date times are reversed."); TimeInterval timeInterval = new TimeInterval(); timeInterval.startDateTime = startDateTime; timeInterval.endDateTime = endDateTime; return timeInterval; }
@Override public List<JobInfo> findRunningWithoutUpdateSince(OffsetDateTime timeOffset) { return jobs.values().stream() .filter(jobInfo -> !jobInfo.isStopped() && jobInfo.getLastUpdated().isBefore(timeOffset)) .collect(toList()); }
private static boolean isActionable(final LoanDescriptor loanDescriptor) { final OffsetDateTime now = DateUtil.offsetNow(); return loanDescriptor.getLoanCaptchaProtectionEndDateTime() .map(d -> d.isBefore(now)) .orElse(true); }
private static boolean isActionable(final LoanDescriptor loanDescriptor) { final OffsetDateTime now = DateUtil.offsetNow(); return loanDescriptor.getLoanCaptchaProtectionEndDateTime() .map(d -> d.isBefore(now)) .orElse(true); }
/** * This reminder is schedulable if the triggering date is defined and is after now. * @return true if the triggering date is after now, false otherwise. */ @Override public boolean isSchedulable() { final OffsetDateTime triggeringDate = getDateTime(); return triggeringDate != null && !triggeringDate.isBefore(OffsetDateTime.now()); }
private static boolean isOutdated(final StateStorage storage, final String section, final OffsetDateTime threshold) { return storage.getValue(section, Constants.LAST_UPDATED_KEY.getValue()) .map(date -> OffsetDateTime.parse(date).isBefore(threshold)) .orElse(true); }
private static boolean isOutdated(final StateStorage storage, final String section, final OffsetDateTime threshold) { return storage.getValue(section, Constants.LAST_UPDATED_KEY.getValue()) .map(date -> OffsetDateTime.parse(date).isBefore(threshold)) .orElse(true); }
private boolean isOld(long amount, TemporalUnit unit) { return this.value.plus(amount, unit) // .isBefore(OffsetDateTime.now()); }
public boolean isConfirmationExpired(long expirationPeriodMs) { if (isNotConfirmed()) { return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS) .isBefore(OffsetDateTime.now()); } return false; }
public boolean isConfirmationExpired(long expirationPeriodMs) { if (isNotConfirmed()) { return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS) .isBefore(OffsetDateTime.now()); } return false; }
@JsonIgnore public boolean isHistoric(OffsetDateTime dateTime) { return dateTime.isBefore(OffsetDateTime.of(getFirstPublishedDate().atTime(LocalTime.MIDNIGHT), dateTime.getOffset())); }
public boolean isConfirmationExpired(long expirationPeriodMs) { if (isNotConfirmed()) { return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS) .isBefore(OffsetDateTime.now()); } return false; }
private OffsetDateTime next(OffsetDateTime from, boolean forward) { OffsetDateTime to; if (forward) { to = this._intervalDate == null ? from : from.plus(this._intervalDate); to = this._intervalTime == null ? to : to.plus(this._intervalTime); if (this._end != null && to.isAfter(this._end)) to = this._end; } else { to = this._intervalDate == null ? from : from.minus(this._intervalDate); to = this._intervalTime == null ? to : to.minus(this._intervalTime); if (this._end != null && to.isBefore(this._start)) to = this._start; } return to; }