java.time.OffsetDateTime.isBefore()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(133)

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

OffsetDateTime.isBefore介绍

[英]Checks if the instant of this date-time is before that of the specified date-time.

This method differs from the comparison in #compareTo in that it only compares the instant of the date-time. This is equivalent to using dateTime1.toInstant().isBefore(dateTime2.toInstant());.
[中]检查此日期时间的瞬间是否早于指定日期时间。
这种方法不同于#compare to中的比较,因为它只比较日期和时间的瞬间。这相当于使用dateTime1。toInstant()。isBefore(dateTime2.toInstant());。

代码示例

代码示例来源:origin: prontera/spring-cloud-rest-tcc

  1. /**
  2. * 直接向服务查询, 不再自作聪明地在本地进行过期时间检查, 以免无法区分not found与conflict
  3. */
  4. @Deprecated
  5. private void checkExpireInLocal(TccRequest request, List<Participant> participantLinks) {
  6. // 获取最接近过期的时间
  7. final OffsetDateTime theClosestToExpire = fetchTheRecentlyExpireTime(participantLinks);
  8. if (theClosestToExpire.minusSeconds(LEEWAY).isBefore(OffsetDateTime.now())) {
  9. // 释放全部资源
  10. cancel(request);
  11. throw new ReservationAlmostToExpireException("there are resources be about to expire at " + theClosestToExpire);
  12. }
  13. }

代码示例来源:origin: org.assertj/assertj-core

  1. /**
  2. * Verifies that the actual {@code OffsetDateTime} is after or equals to the given one.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z"))
  6. * .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));</code></pre>
  7. *
  8. * @param other the given {@link java.time.OffsetDateTime}.
  9. * @return this assertion object.
  10. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}.
  11. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}.
  12. * @throws AssertionError if the actual {@code OffsetDateTime} is not after or equals to the given one.
  13. */
  14. public SELF isAfterOrEqualTo(OffsetDateTime other) {
  15. Objects.instance().assertNotNull(info, actual);
  16. assertOffsetDateTimeParameterIsNotNull(other);
  17. if (actual.isBefore(other)) {
  18. throw Failures.instance().failure(info, shouldBeAfterOrEqualsTo(actual, other));
  19. }
  20. return myself;
  21. }

代码示例来源:origin: org.assertj/assertj-core

  1. /**
  2. * Verifies that the actual {@code OffsetDateTime} is <b>strictly</b> before the given one.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));</code></pre>
  6. *
  7. * @param other the given {@link java.time.OffsetDateTime}.
  8. * @return this assertion object.
  9. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}.
  10. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}.
  11. * @throws AssertionError if the actual {@code OffsetDateTime} is not strictly before the given one.
  12. */
  13. public SELF isBefore(OffsetDateTime other) {
  14. Objects.instance().assertNotNull(info, actual);
  15. assertOffsetDateTimeParameterIsNotNull(other);
  16. if (!actual.isBefore(other)) {
  17. throw Failures.instance().failure(info, shouldBeBefore(actual, other));
  18. }
  19. return myself;
  20. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. /**
  2. * Verifies that the actual {@code OffsetDateTime} is <b>strictly</b> before the given one.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));</code></pre>
  6. *
  7. * @param other the given {@link java.time.OffsetDateTime}.
  8. * @return this assertion object.
  9. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}.
  10. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}.
  11. * @throws AssertionError if the actual {@code OffsetDateTime} is not strictly before the given one.
  12. */
  13. public SELF isBefore(OffsetDateTime other) {
  14. Objects.instance().assertNotNull(info, actual);
  15. assertOffsetDateTimeParameterIsNotNull(other);
  16. if (!actual.isBefore(other)) {
  17. throw Failures.instance().failure(info, shouldBeBefore(actual, other));
  18. }
  19. return myself;
  20. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. /**
  2. * Verifies that the actual {@code OffsetDateTime} is after or equals to the given one.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z"))
  6. * .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));</code></pre>
  7. *
  8. * @param other the given {@link java.time.OffsetDateTime}.
  9. * @return this assertion object.
  10. * @throws AssertionError if the actual {@code OffsetDateTime} is {@code null}.
  11. * @throws IllegalArgumentException if other {@code OffsetDateTime} is {@code null}.
  12. * @throws AssertionError if the actual {@code OffsetDateTime} is not after or equals to the given one.
  13. */
  14. public SELF isAfterOrEqualTo(OffsetDateTime other) {
  15. Objects.instance().assertNotNull(info, actual);
  16. assertOffsetDateTimeParameterIsNotNull(other);
  17. if (actual.isBefore(other)) {
  18. throw Failures.instance().failure(info, shouldBeAfterOrEqualsTo(actual, other));
  19. }
  20. return myself;
  21. }

代码示例来源:origin: de.adorsys.psd2/consent-management-lib

  1. public boolean isBlockingExpired() {
  2. return Optional.ofNullable(blockingExpirationTimestamp)
  3. .map(timestamp -> timestamp.isBefore(OffsetDateTime.now()))
  4. .orElse(false);
  5. }
  6. }

代码示例来源:origin: adorsys/xs2a

  1. public boolean isBlockingExpired() {
  2. return Optional.ofNullable(blockingExpirationTimestamp)
  3. .map(timestamp -> timestamp.isBefore(OffsetDateTime.now()))
  4. .orElse(false);
  5. }
  6. }

代码示例来源:origin: openmhealth/schemas

  1. public static TimeInterval ofStartDateTimeAndEndDateTime(OffsetDateTime startDateTime, OffsetDateTime endDateTime) {
  2. checkNotNull(startDateTime, "A start date time hasn't been specified.");
  3. checkNotNull(endDateTime, "An end date time hasn't been specified.");
  4. checkArgument(!endDateTime.isBefore(startDateTime), "The specified start and end date times are reversed.");
  5. TimeInterval timeInterval = new TimeInterval();
  6. timeInterval.startDateTime = startDateTime;
  7. timeInterval.endDateTime = endDateTime;
  8. return timeInterval;
  9. }

代码示例来源:origin: otto-de/edison-microservice

  1. @Override
  2. public List<JobInfo> findRunningWithoutUpdateSince(OffsetDateTime timeOffset) {
  3. return jobs.values().stream()
  4. .filter(jobInfo -> !jobInfo.isStopped() && jobInfo.getLastUpdated().isBefore(timeOffset))
  5. .collect(toList());
  6. }

代码示例来源:origin: RoboZonky/robozonky

  1. private static boolean isActionable(final LoanDescriptor loanDescriptor) {
  2. final OffsetDateTime now = DateUtil.offsetNow();
  3. return loanDescriptor.getLoanCaptchaProtectionEndDateTime()
  4. .map(d -> d.isBefore(now))
  5. .orElse(true);
  6. }

代码示例来源:origin: com.github.robozonky/robozonky-app

  1. private static boolean isActionable(final LoanDescriptor loanDescriptor) {
  2. final OffsetDateTime now = DateUtil.offsetNow();
  3. return loanDescriptor.getLoanCaptchaProtectionEndDateTime()
  4. .map(d -> d.isBefore(now))
  5. .orElse(true);
  6. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. /**
  2. * This reminder is schedulable if the triggering date is defined and is after now.
  3. * @return true if the triggering date is after now, false otherwise.
  4. */
  5. @Override
  6. public boolean isSchedulable() {
  7. final OffsetDateTime triggeringDate = getDateTime();
  8. return triggeringDate != null && !triggeringDate.isBefore(OffsetDateTime.now());
  9. }

代码示例来源:origin: com.github.robozonky/robozonky-common

  1. private static boolean isOutdated(final StateStorage storage, final String section,
  2. final OffsetDateTime threshold) {
  3. return storage.getValue(section, Constants.LAST_UPDATED_KEY.getValue())
  4. .map(date -> OffsetDateTime.parse(date).isBefore(threshold))
  5. .orElse(true);
  6. }

代码示例来源:origin: RoboZonky/robozonky

  1. private static boolean isOutdated(final StateStorage storage, final String section,
  2. final OffsetDateTime threshold) {
  3. return storage.getValue(section, Constants.LAST_UPDATED_KEY.getValue())
  4. .map(date -> OffsetDateTime.parse(date).isBefore(threshold))
  5. .orElse(true);
  6. }

代码示例来源:origin: am.ik.blog/blog-domain

  1. private boolean isOld(long amount, TemporalUnit unit) {
  2. return this.value.plus(amount, unit) //
  3. .isBefore(OffsetDateTime.now());
  4. }

代码示例来源:origin: de.adorsys.psd2/consent-management-lib

  1. public boolean isConfirmationExpired(long expirationPeriodMs) {
  2. if (isNotConfirmed()) {
  3. return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS)
  4. .isBefore(OffsetDateTime.now());
  5. }
  6. return false;
  7. }

代码示例来源:origin: de.adorsys.psd2/consent-management-lib

  1. public boolean isConfirmationExpired(long expirationPeriodMs) {
  2. if (isNotConfirmed()) {
  3. return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS)
  4. .isBefore(OffsetDateTime.now());
  5. }
  6. return false;
  7. }

代码示例来源:origin: kiegroup/optaweb-employee-rostering

  1. @JsonIgnore
  2. public boolean isHistoric(OffsetDateTime dateTime) {
  3. return dateTime.isBefore(OffsetDateTime.of(getFirstPublishedDate().atTime(LocalTime.MIDNIGHT), dateTime.getOffset()));
  4. }

代码示例来源:origin: adorsys/xs2a

  1. public boolean isConfirmationExpired(long expirationPeriodMs) {
  2. if (isNotConfirmed()) {
  3. return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS)
  4. .isBefore(OffsetDateTime.now());
  5. }
  6. return false;
  7. }

代码示例来源:origin: org.pageseeder.flint/pso-flint-lucene

  1. private OffsetDateTime next(OffsetDateTime from, boolean forward) {
  2. OffsetDateTime to;
  3. if (forward) {
  4. to = this._intervalDate == null ? from : from.plus(this._intervalDate);
  5. to = this._intervalTime == null ? to : to.plus(this._intervalTime);
  6. if (this._end != null && to.isAfter(this._end)) to = this._end;
  7. } else {
  8. to = this._intervalDate == null ? from : from.minus(this._intervalDate);
  9. to = this._intervalTime == null ? to : to.minus(this._intervalTime);
  10. if (this._end != null && to.isBefore(this._start)) to = this._start;
  11. }
  12. return to;
  13. }

相关文章