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


Java Period.months方法代碼示例

本文整理匯總了Java中org.joda.time.Period.months方法的典型用法代碼示例。如果您正苦於以下問題:Java Period.months方法的具體用法?Java Period.months怎麽用?Java Period.months使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.Period的用法示例。


在下文中一共展示了Period.months方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPeriod

import org.joda.time.Period; //導入方法依賴的package包/類
private Period getPeriod(BaseRequest<JobsArchiveDto> request) {
    Period period;
    if (request.getDto().getThresholdUnit().equals(ThresholdType.MONTHS.toString())) {
        period = Period.months(request.getDto().getThresholdValue());
    } else {
        period = Period.years(request.getDto().getThresholdValue());
    }
    return period;
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:10,代碼來源:ArchiveService.java

示例2: execute

import org.joda.time.Period; //導入方法依賴的package包/類
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    GetJobsArchiveServiceApi jobsArchiveService = (GetJobsArchiveServiceApi) context.getMergedJobDataMap().get(GetJobsArchiveServiceApi.class.getName());
    ArchiveServiceApi archiveService = (ArchiveServiceApi) context.getMergedJobDataMap().get(ArchiveServiceApi.class.getName());

    try {
        BaseDtoResponse<JobsArchiveDto> reponse = jobsArchiveService.dispatch(new Request() {
        });

        Period period = new Period();
        if (FreqType.valueOf(reponse.getDto().getFrequency()) == FreqType.MONTHLY) {
            period = Period.months(1);
        } else {
            period = Period.weeks(1);
        }
        DateTime futureJob = new DateTime(reponse.getDto().getLastTriggerTimestamp()).plus(period);

        if (reponse.getDto().getLastTriggerTimestamp() == null || futureJob.isBeforeNow()) {
            log.info("Archiving Job Trigggered at : " + new Date());
            BaseRequest<JobsArchiveDto> request = new BaseRequest<JobsArchiveDto>();
            request.setDto(new JobsArchiveDto());
            request.getDto().setId(1L);
            archiveService.dispatch(request);
        }
    } catch (Exception e) {
        log.error("Failure during archive operation", e);
        StaticRegistry.alertGenerator().processSystemFailureEvent(SystemFailureType.ARCHIVE_FAILURE,
                new LockObjectReference(1L, "Archive Settings", ObjectType.ARCHIVE),
                "Failure during archive operation " + e.getMessage());
    }
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:32,代碼來源:ArchiveScheduledJob.java


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