本文整理了Java中java.time.OffsetDateTime.isAfter()
方法的一些代码示例,展示了OffsetDateTime.isAfter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.isAfter()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:isAfter
[英]Checks if the instant of this date-time is after that of the specified date-time.
This method differs from the comparison in #compareTo and #equals in that it only compares the instant of the date-time. This is equivalent to using dateTime1.toInstant().isAfter(dateTime2.toInstant());.
[中]检查此日期时间的瞬间是否在指定日期时间的瞬间之后。
这种方法不同于#compareTo和#equals中的比较,因为它只比较日期和时间的瞬间。这相当于使用dateTime1。toInstant()。isAfter(dateTime2.toInstant());。
代码示例来源:origin: prontera/spring-cloud-rest-tcc
private OffsetDateTime fetchTheRecentlyExpireTime(List<Participant> participantLink) {
Preconditions.checkNotNull(participantLink);
// 计算出过期时间集合
final List<OffsetDateTime> dateTimeList = participantLink.stream()
.flatMap(x -> Stream.of(x.getExpireTime()))
.filter(x -> x.isAfter(OffsetDateTime.now()))
.sorted()
.collect(Collectors.toList());
// 检查是否具有已经过期的事务
if (dateTimeList.size() != participantLink.size()) {
throw new ReservationExpireException("there has a expired transaction");
}
// 检测是否将近过期, 集合经过Validator检查必有一个元素
return dateTimeList.get(0);
}
代码示例来源:origin: org.postgresql/postgresql
public synchronized String toString(OffsetDateTime offsetDateTime) {
if (offsetDateTime.isAfter(MAX_OFFSET_DATETIME)) {
return "infinity";
} else if (OffsetDateTime.MIN.equals(offsetDateTime)) {
return "-infinity";
}
sbuf.setLength(0);
int nano = offsetDateTime.getNano();
if (nanosExceed499(nano)) {
// Technically speaking this is not a proper rounding, however
// it relies on the fact that appendTime just truncates 000..999 nanosecond part
offsetDateTime = offsetDateTime.plus(ONE_MICROSECOND);
}
LocalDateTime localDateTime = offsetDateTime.toLocalDateTime();
LocalDate localDate = localDateTime.toLocalDate();
appendDate(sbuf, localDate);
sbuf.append(' ');
appendTime(sbuf, localDateTime.toLocalTime());
appendTimeZone(sbuf, offsetDateTime.getOffset());
appendEra(sbuf, localDate);
return sbuf.toString();
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Verifies that the actual {@code OffsetDateTime} is <b>strictly</b> after the given one.
* <p>
* Example :
* <pre><code class='java'> assertThat(parse("2000-01-01T00:00:00Z")).isAfter(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 strictly after the given one.
*/
public SELF isAfter(OffsetDateTime other) {
Objects.instance().assertNotNull(info, actual);
assertOffsetDateTimeParameterIsNotNull(other);
if (!actual.isAfter(other)) {
throw Failures.instance().failure(info, shouldBeAfter(actual, other));
}
return myself;
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Verifies that the actual {@code OffsetDateTime} is before or equals to the given one.
* <p>
* Example :
* <pre><code class='java'> assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo(parse("2000-01-01T23:59:59Z"))
* .isBeforeOrEqualTo(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 before or equals to the given one.
*/
public SELF isBeforeOrEqualTo(OffsetDateTime other) {
Objects.instance().assertNotNull(info, actual);
assertOffsetDateTimeParameterIsNotNull(other);
if (actual.isAfter(other)) {
throw Failures.instance().failure(info, shouldBeBeforeOrEqualsTo(actual, other));
}
return myself;
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Verifies that the actual {@code OffsetDateTime} is <b>strictly</b> after the given one.
* <p>
* Example :
* <pre><code class='java'> assertThat(parse("2000-01-01T00:00:00Z")).isAfter(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 strictly after the given one.
*/
public SELF isAfter(OffsetDateTime other) {
Objects.instance().assertNotNull(info, actual);
assertOffsetDateTimeParameterIsNotNull(other);
if (!actual.isAfter(other)) {
throw Failures.instance().failure(info, shouldBeAfter(actual, other));
}
return myself;
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Verifies that the actual {@code OffsetDateTime} is before or equals to the given one.
* <p>
* Example :
* <pre><code class='java'> assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo(parse("2000-01-01T23:59:59Z"))
* .isBeforeOrEqualTo(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 before or equals to the given one.
*/
public SELF isBeforeOrEqualTo(OffsetDateTime other) {
Objects.instance().assertNotNull(info, actual);
assertOffsetDateTimeParameterIsNotNull(other);
if (actual.isAfter(other)) {
throw Failures.instance().failure(info, shouldBeBeforeOrEqualsTo(actual, other));
}
return myself;
}
代码示例来源:origin: stackoverflow.com
public class Scratch {
public static void main(String... args) throws Exception {
final OffsetDateTime odtMinusSeven = OffsetDateTime.of(2016, 01, 01, 8, 30, 0, 0, ZoneOffset.ofHours(-7));
final OffsetDateTime odtMinusSix = OffsetDateTime.of(2016, 01, 01, 8, 30, 0, 0, ZoneOffset.ofHours(-6));
System.out.println(odtMinusSeven.isAfter(odtMinusSix));
// true
}
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
private static void checkPeriod(final OffsetDateTime startDateTime,
final OffsetDateTime endDateTime) {
Objects.requireNonNull(startDateTime);
Objects.requireNonNull(endDateTime);
if (startDateTime.isAfter(endDateTime) || startDateTime.isEqual(endDateTime)) {
throw new IllegalArgumentException("The end datetime must be after the start datetime");
}
}
代码示例来源:origin: de.adorsys.psd2/consent-management-lib
public boolean isNotExpired() {
return redirectUrlExpirationTimestamp.isAfter(OffsetDateTime.now());
}
}
代码示例来源:origin: kiegroup/optaweb-employee-rostering
public static boolean doTimeslotsIntersect(OffsetDateTime start1, OffsetDateTime end1, OffsetDateTime start2, OffsetDateTime end2) {
return !start1.isAfter(end2) && !end1.isBefore(start2);
}
代码示例来源:origin: adorsys/xs2a
public boolean isNotExpired() {
return redirectUrlExpirationTimestamp.isAfter(OffsetDateTime.now());
}
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
public boolean hasExpired() {
OffsetDateTime expirationDateTime = OffsetDateTime.ofInstant(
Instant.ofEpochSecond(expirationTime), ZoneId.systemDefault());
OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());
return now.isAfter(expirationDateTime);
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
public boolean hasExpired() {
OffsetDateTime expirationDateTime = OffsetDateTime.ofInstant(
Instant.ofEpochSecond(expirationTime), ZoneId.systemDefault());
OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());
return now.isAfter(expirationDateTime);
}
代码示例来源:origin: PacktPublishing/OAuth-2.0-Cookbook
public boolean hasExpired() {
OffsetDateTime expirationDateTime = OffsetDateTime.ofInstant(
Instant.ofEpochSecond(expirationTime), ZoneId.systemDefault());
OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());
return now.isAfter(expirationDateTime);
}
代码示例来源:origin: com.github.robozonky/robozonky-notifications
private Stream<OffsetDateTime> filterValidTimestamps(final Set<OffsetDateTime> timestamps) {
final OffsetDateTime now = DateUtil.offsetNow();
return timestamps.stream().filter(timestamp -> timestamp.plus(period).isAfter(now));
}
代码示例来源:origin: RoboZonky/robozonky
private Stream<OffsetDateTime> filterValidTimestamps(final Set<OffsetDateTime> timestamps) {
final OffsetDateTime now = DateUtil.offsetNow();
return timestamps.stream().filter(timestamp -> timestamp.plus(period).isAfter(now));
}
代码示例来源:origin: rocks.xmpp/xmpp-extensions-common
/**
* Creates a headers element with a time period.
*
* @param start The start date.
* @param stop The stop date.
* @return The header.
* @see <a href="https://xmpp.org/extensions/xep-0149.html">XEP-0149: Time Periods</a>
*/
public static Headers ofTimePeriod(OffsetDateTime start, OffsetDateTime stop) {
// If both a start time and a stop time are specified, the stop time MUST be later than the start time.
if (start.isAfter(stop)) {
throw new IllegalArgumentException("start date must not be after the start date.");
}
return of(Header.ofStartDate(start), Header.ofStopDate(stop));
}
代码示例来源:origin: RoboZonky/robozonky
private Either<InvestmentFailure, BigDecimal> investOrDelegateOnCaptcha(final RecommendedLoan r) {
final Optional<OffsetDateTime> captchaEndDateTime =
r.descriptor().getLoanCaptchaProtectionEndDateTime();
final boolean isCaptchaProtected = captchaEndDateTime.isPresent() &&
captchaEndDateTime.get().isAfter(DateUtil.offsetNow());
final boolean confirmationSupported = this.provider != null;
if (!isCaptchaProtected) {
return this.investLocallyFailingOnCaptcha(r);
} else if (confirmationSupported) {
return this.delegateOrReject(r);
}
LOGGER.warn("CAPTCHA protected, no support for delegation. Not investing: {}.", r);
return Either.left(InvestmentFailure.REJECTED);
}
代码示例来源:origin: org.pageseeder.flint/pso-flint-lucene
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;
}
代码示例来源:origin: net.aholbrook.paseto/core
@Override
public void check(Token token, VerificationContext context) {
OffsetDateTime time = this.time == null ? OffsetDateTime.now(Clock.systemUTC()) : this.time;
if (token.getIssuedAt() == null) {
throw new MissingClaimException(Token.CLAIM_ISSUED_AT, NAME, token);
}
if (token.getIssuedAt().minus(allowableDrift).isAfter(time)) {
throw new IssuedInFutureException(time, token.getIssuedAt(), NAME, token);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!