本文整理了Java中java.time.LocalDateTime.plusSeconds()
方法的一些代码示例,展示了LocalDateTime.plusSeconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.plusSeconds()
方法的具体详情如下:
包路径:java.time.LocalDateTime
类名称:LocalDateTime
方法名:plusSeconds
[英]Returns a copy of this LocalDateTime with the specified period in seconds added.
This instance is immutable and unaffected by this method call.
[中]返回此LocalDateTime的副本,并添加指定的时间段(以秒为单位)。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: yu199195/Raincat
/**
* 计算 second 秒后的时间.
*
* @param date 长日期
* @param second 需要增加的秒数
* @return 增加后的日期
*/
public static LocalDateTime addSecond(final LocalDateTime date, final int second) {
return date.plusSeconds(second);
}
代码示例来源:origin: wuyouzhuguli/SpringAll
public ImageCode(BufferedImage image, String code, int expireIn) {
this.image = image;
this.code = code;
this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
}
代码示例来源:origin: wuyouzhuguli/SpringAll
public SmsCode(String code, int expireIn) {
this.code = code;
this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
}
代码示例来源:origin: lets-blade/blade
/**
* Sets the Date and Cache headers for the HTTP Response
*
* @param response HTTP response
* @param fileToCache file to extract content type
*/
private void setDateAndCacheHeaders(HttpResponse response, File fileToCache) {
response.headers().set(HttpConst.DATE, DateKit.gmtDate());
// Add cache headers
if (httpCacheSeconds > 0) {
response.headers().set(HttpConst.EXPIRES, DateKit.gmtDate(LocalDateTime.now().plusSeconds(httpCacheSeconds)));
response.headers().set(HttpConst.CACHE_CONTROL, "private, max-age=" + httpCacheSeconds);
if (null != fileToCache) {
response.headers().set(HttpConst.LAST_MODIFIED, DateKit.gmtDate(new Date(fileToCache.lastModified())));
} else {
response.headers().set(HttpConst.LAST_MODIFIED, DateKit.gmtDate(LocalDateTime.now().plusDays(-1)));
}
}
}
代码示例来源:origin: lets-blade/blade
/**
* Sets the Date and Cache headers for the HTTP Response
*
* @param response HTTP response
* @param fileToCache file to extract content type
*/
private void setDateAndCacheHeaders(HttpResponse response, File fileToCache) {
response.headers().set(HttpConst.DATE, DateKit.gmtDate());
// Add cache headers
if (httpCacheSeconds > 0) {
response.headers().set(HttpConst.EXPIRES, DateKit.gmtDate(LocalDateTime.now().plusSeconds(httpCacheSeconds)));
response.headers().set(HttpConst.CACHE_CONTROL, "private, max-age=" + httpCacheSeconds);
if (null != fileToCache) {
response.headers().set(HttpConst.LAST_MODIFIED, DateKit.gmtDate(new Date(fileToCache.lastModified())));
} else {
response.headers().set(HttpConst.LAST_MODIFIED, DateKit.gmtDate(LocalDateTime.now().plusDays(-1)));
}
}
}
代码示例来源:origin: lets-blade/blade
@Test
public void testPrettyTime() {
Assert.assertEquals("去年", DateKit.prettyTime(LocalDateTime.now().plusYears(-1), Locale.CHINESE));
Assert.assertEquals("上个月", DateKit.prettyTime(LocalDateTime.now().plusMonths(-1), Locale.CHINESE));
Assert.assertEquals("上周", DateKit.prettyTime(LocalDateTime.now().plusWeeks(-1), Locale.CHINESE));
Assert.assertEquals("昨天", DateKit.prettyTime(LocalDateTime.now().plusDays(-1), Locale.CHINESE));
Assert.assertEquals("1小时前", DateKit.prettyTime(LocalDateTime.now().plusHours(-1), Locale.CHINESE));
Assert.assertEquals("1分钟前", DateKit.prettyTime(LocalDateTime.now().plusMinutes(-1), Locale.CHINESE));
Assert.assertEquals("刚刚", DateKit.prettyTime(LocalDateTime.now().plusSeconds(-1), Locale.CHINESE));
Assert.assertEquals("10秒前", DateKit.prettyTime(LocalDateTime.now().plusSeconds(-10), Locale.CHINESE));
}
代码示例来源:origin: SeanDragon/protools
public DatePlus addSeconds(long seconds) {
this.localDateTime = this.localDateTime.plusSeconds(seconds);
return this;
}
代码示例来源:origin: alibaba/jetcache
case SECONDS:
if (60 % time == 0) {
t = t.plusSeconds(time - t.getSecond() % time);
} else {
t = t.plusSeconds(1);
代码示例来源:origin: pig4cloud/pig
public ImageCode(BufferedImage image, String sRand, int defaultImageExpire) {
this.image = image;
this.code = sRand;
this.expireTime = LocalDateTime.now().plusSeconds(defaultImageExpire);
}
}
代码示例来源:origin: eclipse/smarthome
/**
* Calculate if the token is expired against the given time.
* It also returns true even if the token is not initialized (i.e. object newly created).
*
* @param givenTime To calculate if the token is expired against the givenTime.
* @param tokenExpiresInBuffer A positive integer in seconds to act as additional buffer to the calculation.
* This causes the OAuthToken to expire earlier then the stated expiry-time given
* by the authorization server.
*
* @return true if object is not-initialized, or expired, or expired early due to buffer
*/
public boolean isExpired(@NonNull LocalDateTime givenTime, int tokenExpiresInBuffer) {
return createdOn == null
|| createdOn.plusSeconds(expiresIn).minusSeconds(tokenExpiresInBuffer).isBefore(givenTime);
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns a {@link java.time.LocalDateTime} that is {@code seconds} seconds after this date/time.
*
* @param self a LocalDateTime
* @param seconds the number of seconds to add
* @return a LocalDateTime
* @since 2.5.0
*/
public static LocalDateTime plus(final LocalDateTime self, long seconds) {
return self.plusSeconds(seconds);
}
代码示例来源:origin: imooc-java/security
/**
*
* @param code 随机数
* @param expireInt 有效时间(秒)
*/
public ValidateCode(String code, int expireInt) {
this(code, LocalDateTime.now().plusSeconds(expireInt));
}
代码示例来源:origin: imooc-java/security
/**
* @param image 根据随机数生成的图片
* @param code 随机数
* @param expireInt 有效时间(秒)
*/
public ImageCode(BufferedImage image, String code, int expireInt) {
this(image, code, LocalDateTime.now().plusSeconds(expireInt));
}
代码示例来源:origin: drallieiv/KinanCity
@Override
public void onServerError(R resource) {
WaitQueueSpaced<R> ressource = ressourceQueueMap.get(resource);
if (ressource != null) {
ressource.setLastUse(LocalDateTime.now().plusSeconds(UNBAN_COOLDOWN));
}
}
}
代码示例来源:origin: nl.psek.fitnesse/psek-fitnesse-fixtures-general
/**
* Returns the supplied time plus a number of Seconds in the specified output format.
*
* @param numberOfSeconds the number of Seconds in the future based on the supplied time.
* @return the time.
*/
public String giveTimestampPlusNumberOfSeconds(String time, int numberOfSeconds, String dateFormat) {
return getTime(time, dateFormat).plusSeconds(numberOfSeconds).format(getFormat(dateFormat));
}
代码示例来源:origin: youtongluan/sumk
public SumkDate plusSeconds(int seconds) {
if (seconds == 0) {
return this;
}
return of(this.toLocalDateTime().plusSeconds(seconds));
}
代码示例来源:origin: de.adorsys.ledgers/ledgers-sca-service-impl
private boolean isOperationAlreadyExpired(SCAOperationEntity operation) {
boolean hasExpiredStatus = operation.getStatus() == AuthCodeStatus.EXPIRED;
int validitySeconds = operation.getValiditySeconds();
return hasExpiredStatus || LocalDateTime.now().isAfter(operation.getCreated().plusSeconds(validitySeconds));
}
代码示例来源:origin: eventuate-local/eventuate-local
@Test
public void shouldReadPublishedEvent() throws InterruptedException {
BlockingQueue<PublishedEvent> publishedEvents = new LinkedBlockingDeque<>();
CdcProcessor<PublishedEvent> cdcProcessor = createCdcProcessor();
cdcProcessor.start(publishedEvent -> {
publishedEvents.add(publishedEvent);
onEventSent(publishedEvent);
});
String accountCreatedEventData = generateAccountCreatedEvent();
EntityIdVersionAndEventIds entityIdVersionAndEventIds = saveEvent(accountCreatedEventData);
waitForEvent(publishedEvents, entityIdVersionAndEventIds.getEntityVersion(), LocalDateTime.now().plusSeconds(10), accountCreatedEventData);
cdcProcessor.stop();
}
}
代码示例来源:origin: eventuate-local/eventuate-local
@Test
public void shouldReadUnprocessedEventsAfterStartup() throws InterruptedException {
BlockingQueue<PublishedEvent> publishedEvents = new LinkedBlockingDeque<>();
String accountCreatedEventData = generateAccountCreatedEvent();
EntityIdVersionAndEventIds entityIdVersionAndEventIds = saveEvent(accountCreatedEventData);
CdcProcessor<PublishedEvent> cdcProcessor = createCdcProcessor();
cdcProcessor.start(publishedEvents::add);
waitForEvent(publishedEvents, entityIdVersionAndEventIds.getEntityVersion(), LocalDateTime.now().plusSeconds(20), accountCreatedEventData);
cdcProcessor.stop();
}
代码示例来源:origin: networknt/light-eventuate-4j
@Test
public void shouldReadUnprocessedEventsAfterStartup() throws InterruptedException {
BlockingQueue<PublishedEvent> publishedEvents = new LinkedBlockingDeque<>();
String accountCreatedEventData = generateAccountCreatedEvent();
EntityIdVersionAndEventIds entityIdVersionAndEventIds = saveEvent(localAggregateCrud, accountCreatedEventData);
CdcProcessor<PublishedEvent> mySQLCdcProcessor = createCdcProcessor();
mySQLCdcProcessor.start(publishedEvents::add);
waitForEvent(publishedEvents, entityIdVersionAndEventIds.getEntityVersion(), LocalDateTime.now().plusSeconds(20), accountCreatedEventData);
mySQLCdcProcessor.stop();
}
内容来源于网络,如有侵权,请联系作者删除!