List of usage examples for java.time Clock instant
public abstract Instant instant();
From source file:no.digipost.api.useragreements.client.response.ResponseUtils.java
public static Optional<Duration> parseDelayDurationOfRetryAfterHeader(HttpResponse response, Clock clock) { return getValueOfFirstHeader(response, Headers.Retry_After).map(retryAfterValue -> { try {/*from w ww . j a v a2 s . com*/ long parsedSeconds = Long.parseLong(retryAfterValue); return Duration.ofSeconds(parsedSeconds); } catch (NumberFormatException secondsNotParseable) { try { Instant parsedInstant = RFC_1123_DATE_TIME.parse(retryAfterValue, Instant::from); return Duration.between(clock.instant(), parsedInstant); } catch (RuntimeException e) { e.addSuppressed(secondsNotParseable); throw e; } } }); }
From source file:fi.luontola.cqrshotel.reservation.events.PriceOffered.java
public boolean isStillValid(Clock clock) { return expires.isAfter(clock.instant()); }