本文整理匯總了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);
}