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(); }
@Test void refreshesShortlyAfterMidnight() { final StonkyJob instance = new StonkyJob(); final Duration startIn = instance.startIn(); final OffsetDateTime timeToStartOn = OffsetDateTime.now().plus(startIn); final OffsetDateTime timeToStartBefore = timeToStartOn.plusSeconds(1000); final OffsetDateTime tomorrow = LocalDate.now().plusDays(1).atStartOfDay(Defaults.ZONE_ID).toOffsetDateTime(); assertThat(timeToStartOn) .isAfter(tomorrow) .isBefore(timeToStartBefore); }
@Override public OffsetDateTime read(OffsetDateTime reuse) { return EPOCH.plus(column.nextLong(), ChronoUnit.MICROS); } }
public void block(@Nullable Duration lockPeriod) { this.status = TppStatus.BLOCKED; this.blockingExpirationTimestamp = lockPeriod != null ? OffsetDateTime.now().plus(lockPeriod) : null; }
public void block(@Nullable Duration lockPeriod) { this.status = TppStatus.BLOCKED; this.blockingExpirationTimestamp = lockPeriod != null ? OffsetDateTime.now().plus(lockPeriod) : null; }
@Override public OffsetDateTime read(OffsetDateTime reuse) { return EPOCH.plus(column.nextLong() * 1000, ChronoUnit.MICROS); } }
@Override public OffsetDateTime read(Decoder decoder, Object reuse) throws IOException { return EPOCH.plus(decoder.readLong(), ChronoUnit.MICROS); } }
/** * Calculates the amount of time in {@code unit}. * <p> * The start point of time is taken to be {@link Instant#EPOCH}, and the time zone is {@link ZoneOffset#UTC}. * @param unit the unit * @return the amount of time specified by this instance */ public long getAmountOf(final ChronoUnit unit) { final OffsetDateTime epoch = Instant.EPOCH.atOffset(ZoneOffset.UTC); return unit.between(epoch, epoch.plus(this)); } }
@Override public LocalDateTime read(LocalDateTime reuse) { return EPOCH.plus(column.nextLong() * 1000, ChronoUnit.MICROS).toLocalDateTime(); } }
@Override public LocalDateTime read(Decoder decoder, Object reuse) throws IOException { return EPOCH.plus(decoder.readLong(), ChronoUnit.MICROS).toLocalDateTime(); } }
@Override public LocalDateTime read(LocalDateTime reuse) { return EPOCH.plus(column.nextLong(), ChronoUnit.MICROS).toLocalDateTime(); } }
/** * If protected by CAPTCHA, gives the first instant when the CAPTCHA protection is over. * @return Present if loan protected by CAPTCHA, otherwise empty. */ public Optional<OffsetDateTime> getLoanCaptchaProtectionEndDateTime() { final Duration captchaDelay = loan.getRating().getCaptchaDelay(); if (captchaDelay.get(ChronoUnit.SECONDS) == 0) { return Optional.empty(); } else { return Optional.of(loan.getDatePublished().plus(captchaDelay)); } }
/** * If protected by CAPTCHA, gives the first instant when the CAPTCHA protection is over. * @return Present if loan protected by CAPTCHA, otherwise empty. */ public Optional<OffsetDateTime> getLoanCaptchaProtectionEndDateTime() { final Duration captchaDelay = loan.getRating().getCaptchaDelay(); if (captchaDelay.get(ChronoUnit.SECONDS) == 0) { return Optional.empty(); } else { return Optional.of(loan.getDatePublished().plus(captchaDelay)); } }
public boolean isConfirmationExpired(long expirationPeriodMs) { if (isNotConfirmed()) { return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS) .isBefore(OffsetDateTime.now()); } return false; }
private JobInfo someRunningJobInfo(final String jobId, final String type, final OffsetDateTime started) { return JobInfo.newJobInfo( jobId, type, started, started.plus(1, SECONDS), Optional.empty(), OK, Collections.emptyList(), systemDefaultZone(), "localhost" ); } }
private boolean beforeLastLoadedFromPersistenceLayer(final EmailSchedulingData emailSchedulingData) { if (!hasPersistence || !hasElements()) { return true; } final EmailSchedulingData least = getLeastOfAllLast().get(); final int scheduledDateTimeComparison = emailSchedulingData.getScheduledDateTime().compareTo(least.getScheduledDateTime().plus(queuabilityDelta)); return scheduledDateTimeComparison < 0 || (scheduledDateTimeComparison == 0 && emailSchedulingData.getAssignedPriority() < least.getAssignedPriority()); }
private OffsetDateTime countRedirectUrlExpirationTimestampForAuthorisationType(CmsAuthorisationType authorisationType) { long redirectUrlExpirationTimeMs; if (authorisationType == CmsAuthorisationType.CANCELLED) { redirectUrlExpirationTimeMs = aspspProfileService.getAspspSettings().getPaymentCancellationRedirectUrlExpirationTimeMs(); } else { redirectUrlExpirationTimeMs = aspspProfileService.getAspspSettings().getRedirectUrlExpirationTimeMs(); } return OffsetDateTime.now().plus(redirectUrlExpirationTimeMs, ChronoUnit.MILLIS); }
private OffsetDateTime countRedirectUrlExpirationTimestampForAuthorisationType(CmsAuthorisationType authorisationType) { long redirectUrlExpirationTimeMs; if (authorisationType == CmsAuthorisationType.CANCELLED) { redirectUrlExpirationTimeMs = aspspProfileService.getAspspSettings().getPaymentCancellationRedirectUrlExpirationTimeMs(); } else { redirectUrlExpirationTimeMs = aspspProfileService.getAspspSettings().getRedirectUrlExpirationTimeMs(); } return OffsetDateTime.now().plus(redirectUrlExpirationTimeMs, ChronoUnit.MILLIS); }
private String saveNewAuthorization(AisConsent aisConsent, AisConsentAuthorizationRequest request) { AisConsentAuthorization consentAuthorization = new AisConsentAuthorization(); consentAuthorization.setExternalId(UUID.randomUUID().toString()); consentAuthorization.setPsuData(psuDataMapper.mapToPsuData(request.getPsuData())); consentAuthorization.setConsent(aisConsent); consentAuthorization.setScaStatus(request.getScaStatus()); consentAuthorization.setRedirectUrlExpirationTimestamp(OffsetDateTime.now().plus(aspspProfileService.getAspspSettings().getRedirectUrlExpirationTimeMs(), ChronoUnit.MILLIS)); return aisConsentAuthorisationRepository.save(consentAuthorization).getExternalId(); }
private String saveNewAuthorization(AisConsent aisConsent, AisConsentAuthorizationRequest request) { AisConsentAuthorization consentAuthorization = new AisConsentAuthorization(); consentAuthorization.setExternalId(UUID.randomUUID().toString()); consentAuthorization.setPsuData(psuDataMapper.mapToPsuData(request.getPsuData())); consentAuthorization.setConsent(aisConsent); consentAuthorization.setScaStatus(request.getScaStatus()); consentAuthorization.setRedirectUrlExpirationTimestamp(OffsetDateTime.now().plus(aspspProfileService.getAspspSettings().getRedirectUrlExpirationTimeMs(), ChronoUnit.MILLIS)); return aisConsentAuthorisationRepository.save(consentAuthorization).getExternalId(); }