當前位置: 首頁>>代碼示例>>Java>>正文


Java ChronoUnit.between方法代碼示例

本文整理匯總了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;
}
 
開發者ID:marcosbarbero,項目名稱:spring-boot-starter-purge-accesslog,代碼行數:30,代碼來源:PurgeTask.java

示例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);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:13,代碼來源:DatumUtil.java

示例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);
}
 
開發者ID:blacklabelops,項目名稱:crow,代碼行數:29,代碼來源:MultiJobScheduler.java


注:本文中的java.time.temporal.ChronoUnit.between方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。