List of usage examples for org.joda.time DateTime minusWeeks
public DateTime minusWeeks(int weeks)
From source file:org.n52.io.IoParameters.java
License:Open Source License
private Interval createDefaultTimespan() { DateTime now = new DateTime(); DateTime lastWeek = now.minusWeeks(1); return new Interval(lastWeek, now); }
From source file:org.n52.io.PreRenderingJob.java
License:Open Source License
public IntervalWithTimeZone createTimespanFromInterval(String timeseriesId, String period) { DateTime now = new DateTime(); if (period.equals("lastDay")) { Interval interval = new Interval(now.minusDays(1), now); return new IntervalWithTimeZone(interval.toString()); } else if (period.equals("lastWeek")) { Interval interval = new Interval(now.minusWeeks(1), now); return new IntervalWithTimeZone(interval.toString()); } else if (period.equals("lastMonth")) { Interval interval = new Interval(now.minusMonths(1), now); return new IntervalWithTimeZone(interval.toString()); } else {//from www . j av a 2 s . co m throw new ResourceNotFoundException( "Unknown interval definition '" + period + "' for timeseriesId " + timeseriesId); } }
From source file:org.n52.io.PreRenderingTask.java
License:Open Source License
public Interval createTimespanFromInterval(String timeseriesId, String interval) { DateTime now = new DateTime(); if (interval.equals("lastDay")) { return new Interval(now.minusDays(1), now); } else if (interval.equals("lastWeek")) { return new Interval(now.minusWeeks(1), now); } else if (interval.equals("lastMonth")) { return new Interval(now.minusMonths(1), now); } else {/*from w w w . jav a 2 s.co m*/ throw new ResourceNotFoundException( "Unknown interval definition '" + interval + "' for timeseriesId " + timeseriesId); } }
From source file:org.n52.io.request.IoParameters.java
License:Open Source License
private IntervalWithTimeZone createDefaultTimespan() { DateTime now = new DateTime(); DateTime lastWeek = now.minusWeeks(1); String interval = lastWeek.toString().concat("/").concat(now.toString()); return new IntervalWithTimeZone(interval); }
From source file:org.n52.io.request.RequestParameterSet.java
License:Open Source License
private String createDefaultTimespan() { DateTime now = new DateTime(); DateTime lastWeek = now.minusWeeks(1); String interval = lastWeek.toString().concat("/").concat(now.toString()); return new IntervalWithTimeZone(interval).toString(); }
From source file:org.n52.io.v1.data.ParameterSet.java
License:Open Source License
private String createDefaultTimespan() { DateTime now = new DateTime(); DateTime lastWeek = now.minusWeeks(1); return new Interval(lastWeek, now).toString(); }
From source file:org.obm.push.bean.FilterType.java
License:Open Source License
public Date getFilteredDate(Date fromDate) { DateTime fromUTCDate = new DateTime(fromDate).withZone(DateTimeZone.UTC); switch (this) { case ALL_ITEMS: return DateUtils.getEpochPlusOneSecondCalendar().getTime(); case ONE_DAY_BACK: return fromUTCDate.minusDays(1).toDate(); case THREE_DAYS_BACK: return fromUTCDate.minusDays(3).toDate(); case ONE_WEEK_BACK: return fromUTCDate.minusWeeks(1).toDate(); case TWO_WEEKS_BACK: return fromUTCDate.minusWeeks(2).toDate(); case ONE_MONTHS_BACK: return fromUTCDate.minusMonths(1).toDate(); case THREE_MONTHS_BACK: return fromUTCDate.minusMonths(3).toDate(); case SIX_MONTHS_BACK: return fromUTCDate.minusMonths(6).toDate(); case FILTER_BY_NO_INCOMPLETE_TASKS: return fromDate; }/*www .j a va 2 s . c o m*/ throw new IllegalStateException("No filtered date available"); }
From source file:rapture.dp.invocable.ArchiveRepoStep.java
License:Open Source License
@Override public String invoke(CallingContext context) { List<String> docRepoNames = readListFromContext(context, DOC_REPO_NAMES); List<String> sysRepoNames = readListFromContext(context, SYS_REPO_NAMES); String versionLimitStr = Kernel.getDecision().getContextValue(context, getWorkerURI(), VERSION_LIMIT); String timeLimitStr = Kernel.getDecision().getContextValue(context, getWorkerURI(), TIME_LIMIT); if (StringUtils.isEmpty(versionLimitStr) && StringUtils.isEmpty(timeLimitStr)) { log.warn("No version limit or time limit is specified, nothing to archive"); return NEXT; }/*w w w . ja v a 2s .c o m*/ int versionLimit = StringUtils.isEmpty(versionLimitStr) ? Integer.MAX_VALUE : Integer.parseInt(versionLimitStr); long timeLimit = 0; if (!StringUtils.isEmpty(timeLimitStr)) { DateTime dateTime = DateTime.now(); int number = Integer.valueOf(timeLimitStr.substring(0, timeLimitStr.length() - 1)); char dateUnit = timeLimitStr.charAt(timeLimitStr.length() - 1); switch (dateUnit) { case 'M': dateTime = dateTime.minusMonths(number); break; case 'W': dateTime = dateTime.minusWeeks(number); break; case 'D': dateTime = dateTime.minusDays(number); break; default: throw RaptureExceptionFactory.create("Invalid date unit " + dateUnit); } timeLimit = dateTime.getMillis(); } boolean ensureVersionLimit = Boolean .parseBoolean(Kernel.getDecision().getContextValue(context, getWorkerURI(), ENSURE_VERSION_LIMIT)); log.info(String.format("Configured to archive %s doc repos and %s system repos.", docRepoNames.size(), sysRepoNames.size())); for (String repoName : docRepoNames) { log.info(String.format("About to archive doc repo %s", repoName)); Kernel.getDoc().archiveRepoDocs(context, repoName, versionLimit, timeLimit, ensureVersionLimit); } for (String repoName : sysRepoNames) { Repository repo = Kernel.INSTANCE.getRepo(repoName); if (repo == null) { log.info(String.format("Repo not found for name '%s'", repoName)); } else { if (repo.isVersioned() && repo instanceof NVersionedRepo) { log.info(String.format("About to archive sys repo %s", repoName)); ((NVersionedRepo) repo).archiveRepoVersions(repoName, versionLimit, timeLimit, ensureVersionLimit, context.getUser()); } else { log.info(String.format( "Sys repo %s is not of type NVersionedRepo, instead it is of type %s, skipping...", repoName, repo.getClass().getName())); } } } return NEXT; }
From source file:rapture.dp.invocable.CheckPrerequisiteStep.java
License:Open Source License
private DateTime getDateTime(DateTime dateTime, String dateWithin, String timeNoEarlierThan) { if (!StringUtils.isEmpty(timeNoEarlierThan)) { DateTime hours = getDateTime(timeNoEarlierThan); if (dateTime == null) dateTime = hours;// w ww. j ava2s .c o m else { dateTime = dateTime.withMillisOfDay(hours.getMillisOfDay()).withZone(hours.getZone()); } } if (!StringUtils.isEmpty(dateWithin)) { int number = Integer.valueOf(dateWithin.substring(0, dateWithin.length() - 1)); char dateUnit = dateWithin.charAt(dateWithin.length() - 1); switch (dateUnit) { case 'M': dateTime = dateTime.minusMonths(number); break; case 'W': dateTime = dateTime.minusWeeks(number); break; case 'D': dateTime = dateTime.minusDays(number); break; case 'H': dateTime = dateTime.minusHours(number); break; case 'B': dateTime = USCalendar.minusBusinessDays(dateTime, number); break; default: throw RaptureExceptionFactory.create("Invalid date unit " + dateUnit); } } return dateTime; }