本文整理了Java中java.time.OffsetDateTime.minusSeconds()
方法的一些代码示例,展示了OffsetDateTime.minusSeconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.minusSeconds()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:minusSeconds
[英]Returns a copy of this OffsetDateTime with the specified period in seconds subtracted.
This instance is immutable and unaffected by this method call.
[中]返回此OffsetDateTime的副本,并减去指定的时间段(以秒为单位)。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: prontera/spring-cloud-rest-tcc
@Override
public Set<EventPublisher> execute(EventPublisherMapper mapper) {
// 取出3秒前已经发送过至队列但是没有收到ack请求的消息,并进行重试
return mapper.selectLimitedEntityByEventStatusBeforeTheSpecifiedUpdateTime(EventStatus.PENDING, 300, OffsetDateTime.now().minusSeconds(3));
}
}
代码示例来源:origin: prontera/spring-cloud-rest-tcc
/**
* 直接向服务查询, 不再自作聪明地在本地进行过期时间检查, 以免无法区分not found与conflict
*/
@Deprecated
private void checkExpireInLocal(TccRequest request, List<Participant> participantLinks) {
// 获取最接近过期的时间
final OffsetDateTime theClosestToExpire = fetchTheRecentlyExpireTime(participantLinks);
if (theClosestToExpire.minusSeconds(LEEWAY).isBefore(OffsetDateTime.now())) {
// 释放全部资源
cancel(request);
throw new ReservationAlmostToExpireException("there are resources be about to expire at " + theClosestToExpire);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns an {@link java.time.OffsetDateTime} that is {@code seconds} seconds before this date/time.
*
* @param self an OffsetDateTime
* @param seconds the number of seconds to subtract
* @return an OffsetDateTime
* @since 2.5.0
*/
public static OffsetDateTime minus(final OffsetDateTime self, long seconds) {
return self.minusSeconds(seconds);
}
代码示例来源:origin: otto-de/edison-microservice
public void killJobsDeadSince(final int seconds) {
final OffsetDateTime timeToMarkJobAsStopped = now(clock).minusSeconds(seconds);
LOG.info(format("JobCleanup: Looking for jobs older than %s ", timeToMarkJobAsStopped));
final List<JobInfo> deadJobs = jobRepository.findRunningWithoutUpdateSince(timeToMarkJobAsStopped);
deadJobs.forEach(deadJob -> killJob(deadJob.getJobId()));
clearRunLocks();
}
代码示例来源:origin: otto-de/edison-microservice
private JobInfo someStoppedJob(final JobInfo.JobStatus jobStatus, int startedSecondsAgo) {
OffsetDateTime now = now();
JobInfo someJob = mock(JobInfo.class);
when(someJob.getJobType()).thenReturn("someJobType");
when(someJob.getJobId()).thenReturn("someId");
when(someJob.getStarted()).thenReturn(now.minusSeconds(startedSecondsAgo));
when(someJob.getStopped()).thenReturn(of(now.minusSeconds(startedSecondsAgo-1)));
when(someJob.getStatus()).thenReturn(jobStatus);
return someJob;
}
代码示例来源:origin: otto-de/edison-microservice
private JobInfo someRunningJob(final JobInfo.JobStatus jobStatus, int startedSecondsAgo) {
OffsetDateTime now = now();
JobInfo someJob = mock(JobInfo.class);
when(someJob.getJobType()).thenReturn("someJobType");
when(someJob.getJobId()).thenReturn("someJobId");
when(someJob.getStarted()).thenReturn(now.minusSeconds(startedSecondsAgo));
when(someJob.getStopped()).thenReturn(empty());
when(someJob.getStatus()).thenReturn(jobStatus);
return someJob;
}
}
内容来源于网络,如有侵权,请联系作者删除!