List of usage examples for org.joda.time Days Days
private Days(int days)
From source file:ch.oakmountain.tpa.solver.PeriodicalTimeFrame.java
License:Apache License
private PeriodicalTimeFrame shiftToStandardWeek(PeriodicalTimeFrame periodicalTimeFrame) { int i = 0;// w w w. j a v a 2s. c o m while (periodicalTimeFrame.isAfterOrEqual(END_OF_WEEK)) { periodicalTimeFrame.isAfterOrEqual(END_OF_WEEK); periodicalTimeFrame = periodicalTimeFrame.minus(Days.days(7)); } while (periodicalTimeFrame.isBefore(START_OF_WEEK)) { periodicalTimeFrame.isBefore(START_OF_WEEK); periodicalTimeFrame = periodicalTimeFrame.plus(Days.days(7)); } return periodicalTimeFrame; }
From source file:ch.oakmountain.tpa.solver.SimpleTrainPathApplication.java
License:Apache License
public SimpleTrainPathApplication(String name, SystemNode from, SystemNode to, PeriodicalTimeFrame startTime, PeriodicalTimeFrame endTime, TrainPathApplication parent, int hardMaximumEarlierDeparture, int hardMinimumDwellTime, int hardMaximumLaterArrival) { this.name = name; this.from = from; this.to = to; this.startTime = startTime; this.endTime = endTime; this.parent = parent; if (!endTime.isWithinBounds(startTime, startTime.plus(Days.days(1)))) { endTime.isWithinBounds(startTime, startTime.plus(Days.days(1))); throw new IllegalArgumentException("End time " + endTime + " is not within 24h from startTime " + startTime + " in request " + name); }//from ww w .j a v a 2 s .com this.params = new TrainPathAllocationProblemPruningParameters(this, hardMaximumEarlierDeparture, hardMinimumDwellTime, hardMaximumLaterArrival); }
From source file:com.blackducksoftware.integration.jira.task.JiraSettingsService.java
License:Apache License
public static List<TicketCreationError> expireOldErrors(final PluginSettings pluginSettings) { logger.debug("Pulling error messages from settings"); final Object errorObject = pluginSettings.get(HubJiraConstants.HUB_JIRA_ERROR); if (errorObject == null) { logger.debug("No error messages found in settings"); return null; }/*from w w w. ja v a2 s. c om*/ if (!(errorObject instanceof String)) { logger.warn( "The error object in settings is invalid (probably stored by an older version of the plugin); discarding it"); pluginSettings.remove(HubJiraConstants.HUB_JIRA_ERROR); return null; } List<TicketCreationError> ticketErrors = null; final String ticketErrorsString = (String) errorObject; try { ticketErrors = TicketCreationError.fromJson(ticketErrorsString); } catch (final Exception e) { logger.warn("Error deserializing JSON string pulled from settings: " + e.getMessage() + "; resettting error message list"); pluginSettings.remove(HubJiraConstants.HUB_JIRA_ERROR); return null; } if ((ticketErrors == null) || ticketErrors.isEmpty()) { logger.debug("No error messages found in settings"); return null; } logger.debug("# error messages pulled from settings: " + ticketErrors.size()); Collections.sort(ticketErrors); final DateTime currentTime = DateTime.now(); final Iterator<TicketCreationError> expirationIterator = ticketErrors.iterator(); while (expirationIterator.hasNext()) { final TicketCreationError ticketError = expirationIterator.next(); final DateTime errorTime = ticketError.getTimeStampDateTime(); if (Days.daysBetween(errorTime, currentTime).isGreaterThan(Days.days(30))) { logger.debug("Removing old error message with timestamp: " + ticketError.getTimeStamp()); expirationIterator.remove(); } } logger.debug("Saving " + ticketErrors.size() + " non-expired error messages in settings"); pluginSettings.put(HubJiraConstants.HUB_JIRA_ERROR, TicketCreationError.toJson(ticketErrors)); return ticketErrors; }
From source file:com.cenrise.test.azkaban.Utils.java
License:Apache License
public static ReadablePeriod parsePeriodString(final String periodStr) { final ReadablePeriod period; final char periodUnit = periodStr.charAt(periodStr.length() - 1); if (periodStr.equals("null") || periodUnit == 'n') { return null; }/*from w w w . ja v a 2 s . c om*/ final int periodInt = Integer.parseInt(periodStr.substring(0, periodStr.length() - 1)); switch (periodUnit) { case 'y': period = Years.years(periodInt); break; case 'M': period = Months.months(periodInt); break; case 'w': period = Weeks.weeks(periodInt); break; case 'd': period = Days.days(periodInt); break; case 'h': period = Hours.hours(periodInt); break; case 'm': period = Minutes.minutes(periodInt); break; case 's': period = Seconds.seconds(periodInt); break; default: throw new IllegalArgumentException("Invalid schedule period unit '" + periodUnit); } return period; }
From source file:com.effektif.workflow.api.model.AfterRelativeTime.java
License:Apache License
public LocalDateTime resolve(LocalDateTime base) { if (this.duration == null || this.durationUnit == null) { return null; }/*from w ww. j a va 2 s .co m*/ ReadablePeriod period = null; if (DAYS.equals(durationUnit)) { period = Days.days(getDurationAsInt()); } else if (WEEKS.equals(durationUnit)) { period = Weeks.weeks(getDurationAsInt()); } else if (HOURS.equals(durationUnit)) { period = Hours.hours(getDurationAsInt()); } else if (MONTHS.equals(durationUnit)) { period = Months.months(getDurationAsInt()); } else if (YEARS.equals(durationUnit)) { period = Years.years(getDurationAsInt()); } else if (MINUTES.equals(durationUnit)) { period = Minutes.minutes(getDurationAsInt()); } else { return null; } LocalDateTime time = base.plus(period); if (atHour != null) { LocalDateTime atTime = time.withTime(atHour, atMinute != null ? atMinute : 0, 0, 0); if (atTime.isBefore(time)) { time = atTime.plusDays(1); } else { time = atTime; } } else if (isDayResolutionOrBigger()) { time = time.withTime(23, 59, 59, 999); } return time; }
From source file:com.mbc.jfin.schedule.impl.AbstractBaseScheduleGenerator.java
License:Open Source License
protected ReadablePeriod multiplyPeriod(ReadablePeriod frequency, int periodCount) throws ScheduleException { if (frequency instanceof Months) { return Months.months(frequency.getValue(0) * periodCount); } else if (frequency instanceof Days) { return Days.days(frequency.getValue(0) * periodCount); } else if (frequency instanceof Weeks) { return Weeks.weeks(frequency.getValue(0) * periodCount); } else if (frequency instanceof Years) { return Years.years(frequency.getValue(0) * periodCount); } else {//ww w . ja va 2s .co m throw new ScheduleException("Unknown frequency type: " + frequency); } }
From source file:com.ning.billing.util.clock.ClockMock.java
License:Apache License
public synchronized void addDays(final int days) { adjustTo(Days.days(days)); }
From source file:controllers.api.DashboardsApiController.java
License:Open Source License
private Duration estimateIntervalStep(String interval) { Duration step;//w w w.jav a2 s. c om switch (interval) { case "minute": step = Minutes.ONE.toStandardDuration(); break; case "hour": step = Hours.ONE.toStandardDuration(); break; case "day": step = Days.ONE.toStandardDuration(); break; case "week": step = Weeks.ONE.toStandardDuration(); break; case "month": step = Days.days(31).toStandardDuration(); break; case "quarter": step = Days.days(31 * 3).toStandardDuration(); break; case "year": step = Days.days(365).toStandardDuration(); break; default: throw new IllegalArgumentException("Invalid duration specified: " + interval); } return step; }
From source file:energy.usef.agr.workflow.nonudi.initialize.AgrNonUdiInitializeEventTrigger.java
License:Apache License
private long createIntervalPeriod() { return Days.days(1).toStandardDuration().getMillis(); }
From source file:energy.usef.agr.workflow.plan.connection.forecast.AgrCommonReferenceQueryEventTrigger.java
License:Apache License
private long createIntervalPeriod() { return Days .days(Integer/*from w ww. j a v a 2 s . c o m*/ .parseInt(configAgr.getProperty(ConfigAgrParam.AGR_INITIALIZE_PLANBOARD_DAYS_INTERVAL))) .toStandardDuration().getMillis(); }