当前位置: 首页>>代码示例>>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;未经允许,请勿转载。