本文整理汇总了Java中java.time.temporal.ChronoUnit.between方法的典型用法代码示例。如果您正苦于以下问题:Java ChronoUnit.between方法的具体用法?Java ChronoUnit.between怎么用?Java ChronoUnit.between使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.temporal.ChronoUnit
的用法示例。
在下文中一共展示了ChronoUnit.between方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPurgeable
import java.time.temporal.ChronoUnit; //导入方法依赖的package包/类
/**
* Checks if this file is not the current access log file and if it is eligible for
* purge according to the last modified time.
*
* @param accessLogPath file from access log directory
* @return A boolean indicating if this file is eligible, or not, for purge
*/
private boolean isPurgeable(final Path accessLogPath) {
boolean purgeable = false;
try {
final String fileName = accessLogPath.getFileName().toString();
if (!fileName.equals(this.currentLogFileNameSupplier.get())
&& fileName.matches(this.pattern)) {
final FileTime lastModifiedTime = getLastModifiedTime(accessLogPath);
final Instant lastModifiedInstant = ofEpochMilli(
lastModifiedTime.toMillis());
final ChronoUnit maxHistoryUnit = this.purgeProperties
.getMaxHistoryUnit();
final long between = maxHistoryUnit.between(lastModifiedInstant, now());
purgeable = between > this.purgeProperties.getMaxHistory();
}
}
catch (final IOException e) {
log.warn(e.getMessage(), e);
}
return purgeable;
}
示例2: bepaalPeriodeTussenDatumsSoepel
import java.time.temporal.ChronoUnit; //导入方法依赖的package包/类
private static Long bepaalPeriodeTussenDatumsSoepel(final Integer begin, final Integer eind, final ChronoUnit periodeEenheid) {
if (begin == null || eind == null) {
return null;
}
final Integer beginDatumSoepel = bepaalEindDatumStrengOfBeginDatumSoepel(begin, false);
final Integer eindDatumSoepel = bepaalBeginDatumStrengOfEindDatumSoepel(eind, false);
final String dateFormat = "%08d";
final LocalDate van = LocalDate.parse(String.format(dateFormat, beginDatumSoepel), FORMATTER);
final LocalDate tot = LocalDate.parse(String.format(dateFormat, eindDatumSoepel), FORMATTER);
return periodeEenheid.between(van, tot);
}
示例3: run
import java.time.temporal.ChronoUnit; //导入方法依赖的package包/类
@Override
public void run() {
ChronoUnit chronoUnit = ChronoUnit.MILLIS;
do {
Job nextJob = jobScheduler.getNextExecutableJob();
if (nextJob != null) {
ZonedDateTime nextExecution = nextJob.getNextExecution();
boolean waitFornextExecution = true;
while (waitFornextExecution && keepRunning && checkJob(nextJob)) {
long timeToNextExecution = chronoUnit.between(ZonedDateTime.now(), nextExecution);
if (timeToNextExecution <= 0) {
LOG.debug("Executing job {}.", nextJob.getJobName());
ExecutionResult executionResult = executorPool.addExecution(nextJob.getExecutor());
if (!ExecutionResult.EXECUTED.equals(executionResult)) {
jobScheduler.notifyFailingJob(nextJob.getExecutor(),executionResult);
}
nextJob.setLastExecution(ZonedDateTime.now());
waitFornextExecution = false;
} else {
LOG.trace("Waiting for next job execution in {} ms.", timeToNextExecution);
waitForNextExecution(timeToNextExecution);
}
}
} else {
waitForNextExecution(MINIMAL_TIME_STEP);
}
} while(keepRunning);
}