本文整理了Java中java.time.ZonedDateTime.plusSeconds()
方法的一些代码示例,展示了ZonedDateTime.plusSeconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.plusSeconds()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:plusSeconds
[英]Returns a copy of this ZonedDateTime with the specified period in seconds added.
This operates on the instant time-line, such that adding one second will always be a duration of one second later. This may cause the local date-time to change by an amount other than one second. Note that this is a different approach to that used by days, months and years.
This instance is immutable and unaffected by this method call.
[中]返回此ZoneDateTime的副本,并添加指定的时间段(以秒为单位)。
这是在即时时间线上操作的,因此添加一秒钟将始终是一秒钟之后的持续时间。这可能会导致本地日期时间的变化量超过1秒。请注意,这与日、月和年使用的方法不同。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: org.elasticsearch/elasticsearch
public ZonedDateTime plusSeconds(long amount) {
return dt.plusSeconds(amount);
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns a {@link java.time.ZonedDateTime} that is {@code seconds} seconds after this date/time.
*
* @param self an ZonedDateTime
* @param seconds the number of seconds to add
* @return a ZonedDateTime
* @since 2.5.0
*/
public static ZonedDateTime plus(final ZonedDateTime self, long seconds) {
return self.plusSeconds(seconds);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
dateTime = dateTime.withNano(0);
} else {
dateTime = dateTime.plusSeconds(sign * num);
dateTime = dateTime.plusSeconds(1);
代码示例来源:origin: cassiomolin/jersey-jwt
/**
* Calculate the expiration date for a token.
*
* @param issuedDate
* @return
*/
private ZonedDateTime calculateExpirationDate(ZonedDateTime issuedDate) {
return issuedDate.plusSeconds(validFor);
}
代码示例来源:origin: KittehOrg/KittehIRCClientLib
/**
* Returns an ISO8601 DateTime string using UTC.
*
* @param duration the time in seconds from now
* @return the date-time string e.g. 2016-01-01T00:00:00Z
*/
private String getExpiryFromDuration(long duration) {
return ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(duration).format(DATE_TIME_FORMATTER);
}
}
代码示例来源:origin: UniversaBlockchain/universa
private ZonedDateTime calcExpiresAt () {
// get number of entries
int entries = 0;
for (UnsName sn: storedNames)
entries += sn.getRecordsCount();
if (entries == 0)
entries = 1;
final int finalEntries = entries;
return prepaidFrom.plusSeconds((long) (prepaidNamesForDays * 24 * 3600 / finalEntries));
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-java-client-core
@JsonCreator
TokensImpl(String accessToken, String refreshToken, @Nullable Long expiresIn) {
if (isEmpty(accessToken))
throw new SphereException("OAuth response must contain an access_token. Was empty.");
this.accessToken = accessToken;
this.refreshToken = refreshToken;
this.expiresIn = expiresIn;
expiresInZonedDateTime = Optional.ofNullable(expiresIn).map(seconds -> ZonedDateTime.now().plusSeconds(seconds)).orElse(null);
}
代码示例来源:origin: io.sphere.sdk.jvm/sphere-java-client-core
@JsonCreator
private Tokens(String accessToken, String refreshToken, Long expiresIn) {
if (isEmpty(accessToken))
throw new SphereException("OAuth response must contain an access_token. Was empty.");
this.accessToken = accessToken;
this.refreshToken = refreshToken;
this.expiresIn = expiresIn;
expiresInZonedDateTime = Optional.ofNullable(expiresIn).map(seconds -> ZonedDateTime.now().plusSeconds(seconds)).orElse(null);
}
代码示例来源:origin: http-builder-ng/http-builder-ng
/**
* Always returns {@link ZonedDateTime}
*
* @return the parsed header type
*/
public ZonedDateTime parse() {
if (isSimpleNumber()) {
return ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(Long.parseLong(getValue()));
} else {
return parse(RFC_1123_DATE_TIME);
}
}
代码示例来源:origin: io.github.http-builder-ng/http-builder-ng-core
/**
* Always returns {@link ZonedDateTime}
*
* @return the parsed header type
*/
public ZonedDateTime parse() {
if (isSimpleNumber()) {
return ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(Long.parseLong(getValue()));
} else {
return parse(RFC_1123_DATE_TIME);
}
}
代码示例来源:origin: org.codehaus.groovy.modules/http-builder-ng-core
/**
* Always returns {@link ZonedDateTime}
*
* @return the parsed header type
*/
public ZonedDateTime parse() {
if (isSimpleNumber()) {
return ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(Long.parseLong(getValue()));
} else {
return parse(RFC_1123_DATE_TIME);
}
}
代码示例来源:origin: io.atlasmap/atlas-core
@AtlasFieldActionInfo(name = "AddSeconds", sourceType = FieldType.ANY_DATE, targetType = FieldType.ANY_DATE, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static ZonedDateTime addSeconds(Action action, ZonedDateTime input) {
if (action == null || !(action instanceof AddSeconds)) {
throw new IllegalArgumentException("Action must be an AddSeconds action");
}
if (input == null) {
return null;
}
AddSeconds addSeconds = (AddSeconds) action;
return input.plusSeconds(addSeconds.getSeconds() == null ? 0L : addSeconds.getSeconds());
}
代码示例来源:origin: com.namics.oss/java-random
@Override
public ZonedDateTime random() {
ZonedDateTime now = ZonedDateTime.now().withZoneSameInstant(ZoneId.of(RandomData.random(ZoneId.getAvailableZoneIds())));
int year = 60 * 60 * 24 * 365;
return now.plusSeconds((long) RandomData.randomInteger(-2 * year, 2 * year));// +- 2 years;
}
代码示例来源:origin: huaweicse/ServiceComb-Company-WorkShop
@Override
public String generate(String username) {
return Jwts.builder()
.setSubject(username)
.setExpiration(Date.from(ZonedDateTime.now().plusSeconds(secondsToExpire).toInstant()))
.signWith(HS512, secretKey)
.compact();
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private ZonedDateTime dateTimeAfterValidFromAndOldValidUntil(final CartDiscount cartDiscount) {
return Optional.ofNullable(cartDiscount.getValidUntil())
.orElse(Optional.ofNullable(cartDiscount.getValidFrom()).orElse(SphereTestUtils.now()).plusSeconds(1000)).plusSeconds(1);
}
}
代码示例来源:origin: apache/cxf
@Override
public void modifySecurityHeader(Element securityHeader) {
if (securityHeader != null) {
// Find the Timestamp + change it.
Element timestampElement =
XMLUtils.findElement(securityHeader, "Timestamp", WSS4JConstants.WSU_NS);
Element createdValue =
XMLUtils.findElement(timestampElement, "Created", WSS4JConstants.WSU_NS);
ZonedDateTime created = ZonedDateTime.parse(createdValue.getTextContent());
// Add 5 seconds
createdValue.setTextContent(DateUtil.getDateTimeFormatter(true).format(created.plusSeconds(5L)));
}
}
代码示例来源:origin: ru.curs/celesta-sql
@Override
public ZonedDateTime prepareZonedDateTimeForParameterSetter(Connection conn, ZonedDateTime z) {
ZoneOffset systemOffset = OffsetDateTime.now().getOffset();
ZoneOffset offset = z.getOffset();
int offsetDifInSeconds = systemOffset.getTotalSeconds() - offset.getTotalSeconds();
return z.plusSeconds(offsetDifInSeconds);
}
代码示例来源:origin: UniversaBlockchain/universa
static Contract createComplexConctract(PrivateKey key, int subcontracts, int n) {
Contract root = createSimpleContract(key);
for(int i = 0; i < subcontracts; i++) {
Contract c = createSimpleContract(key);
c.setExpiresAt(c.getExpiresAt().plusSeconds(i+1+(subcontracts+1)*n));
c.seal();
root.addNewItems(c);
}
root.setExpiresAt(root.getExpiresAt().plusSeconds((subcontracts+1)*n));
root.addSignerKey(key);
root.seal();
return root;
}
代码示例来源:origin: OpenGamma/Strata
public void test_builder_inverseFx() {
ResolvedFxVanillaOption test = sut2();
assertEquals(test.getExpiry(), EXPIRY_DATE_TIME.plusSeconds(1));
assertEquals(test.getExpiryDate(), EXPIRY_DATE_TIME.toLocalDate());
assertEquals(test.getLongShort(), SHORT);
assertEquals(test.getCounterCurrency(), GBP);
assertEquals(test.getPutCall(), PUT);
assertEquals(test.getStrike(), STRIKE_RE);
assertEquals(test.getUnderlying(), FX_RE);
}
代码示例来源:origin: OpenGamma/Strata
static ResolvedFxVanillaOption sut2() {
;
return ResolvedFxVanillaOption.builder()
.longShort(SHORT)
.expiry(EXPIRY_DATE_TIME.plusSeconds(1))
.underlying(FX_RE)
.build();
}
内容来源于网络,如有侵权,请联系作者删除!