本文整理了Java中java.time.OffsetDateTime.plus()
方法的一些代码示例,展示了OffsetDateTime.plus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.plus()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:plus
[英]Returns a copy of this date-time with the specified period added.
This method returns a new date-time based on this date-time with the specified period added. This can be used to add any period that is defined by a unit, for example to add years, months or days. The unit is responsible for the details of the calculation, including the resolution of any edge cases in the calculation. The offset is not part of the calculation and will be unchanged in the result.
This instance is immutable and unaffected by this method call.
[中]返回添加了指定时间段的此日期时间的副本。
此方法基于此日期时间返回新的日期时间,并添加指定的期间。这可用于添加单位定义的任何期间,例如添加年、月或日。该部门负责计算的细节,包括计算中任何边缘情况的解决方案。偏移量不是计算的一部分,在结果中将保持不变。
此实例是不可变的,不受此方法调用的影响。
代码示例来源: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: RoboZonky/robozonky
@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);
}
代码示例来源:origin: Netflix/iceberg
@Override
public OffsetDateTime read(OffsetDateTime reuse) {
return EPOCH.plus(column.nextLong(), ChronoUnit.MICROS);
}
}
代码示例来源:origin: de.adorsys.psd2/consent-management-lib
public void block(@Nullable Duration lockPeriod) {
this.status = TppStatus.BLOCKED;
this.blockingExpirationTimestamp = lockPeriod != null
? OffsetDateTime.now().plus(lockPeriod)
: null;
}
代码示例来源:origin: adorsys/xs2a
public void block(@Nullable Duration lockPeriod) {
this.status = TppStatus.BLOCKED;
this.blockingExpirationTimestamp = lockPeriod != null
? OffsetDateTime.now().plus(lockPeriod)
: null;
}
代码示例来源:origin: Netflix/iceberg
@Override
public OffsetDateTime read(OffsetDateTime reuse) {
return EPOCH.plus(column.nextLong() * 1000, ChronoUnit.MICROS);
}
}
代码示例来源:origin: Netflix/iceberg
@Override
public OffsetDateTime read(Decoder decoder, Object reuse) throws IOException {
return EPOCH.plus(decoder.readLong(), ChronoUnit.MICROS);
}
}
代码示例来源:origin: metatron-app/metatron-discovery
/**
* 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));
}
}
代码示例来源:origin: Netflix/iceberg
@Override
public LocalDateTime read(LocalDateTime reuse) {
return EPOCH.plus(column.nextLong() * 1000, ChronoUnit.MICROS).toLocalDateTime();
}
}
代码示例来源:origin: Netflix/iceberg
@Override
public LocalDateTime read(Decoder decoder, Object reuse) throws IOException {
return EPOCH.plus(decoder.readLong(), ChronoUnit.MICROS).toLocalDateTime();
}
}
代码示例来源:origin: Netflix/iceberg
@Override
public LocalDateTime read(LocalDateTime reuse) {
return EPOCH.plus(column.nextLong(), ChronoUnit.MICROS).toLocalDateTime();
}
}
代码示例来源:origin: com.github.robozonky/robozonky-api
/**
* 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));
}
}
代码示例来源:origin: RoboZonky/robozonky
/**
* 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));
}
}
代码示例来源:origin: de.adorsys.psd2/consent-management-lib
public boolean isConfirmationExpired(long expirationPeriodMs) {
if (isNotConfirmed()) {
return creationTimestamp.plus(expirationPeriodMs, ChronoUnit.MILLIS)
.isBefore(OffsetDateTime.now());
}
return false;
}
代码示例来源:origin: otto-de/edison-microservice
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"
);
}
}
代码示例来源:origin: it.ozimov/spring-boot-email-core
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());
}
代码示例来源:origin: de.adorsys.psd2/consent-management-lib
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);
}
代码示例来源:origin: adorsys/xs2a
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);
}
代码示例来源:origin: adorsys/xs2a
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();
}
代码示例来源:origin: de.adorsys.psd2/consent-management-lib
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();
}
内容来源于网络,如有侵权,请联系作者删除!