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