List of usage examples for org.joda.time Days Days
private Days(int days)
From source file:org.cowboyprogrammer.org.OrgTimestamp.java
License:Open Source License
protected ReadablePeriod parsePeriod(final int t, final String w) { final ReadablePeriod p; if (w.equals("h")) { p = Hours.hours(t);/* w w w .j a v a 2 s . c o m*/ } else if (w.equals("d")) { p = Days.days(t); } else if (w.equals("w")) { p = Weeks.weeks(t); } else if (w.equals("m")) { p = Months.months(t); } else { p = Years.years(t); } return p; }
From source file:org.forgerock.openidm.scheduler.impl.TaskScannerContext.java
License:CDDL license
/** * Retrieve the timeout period from the supplied config. * * @return the timeout period taken from the config */// w ww. jav a 2 s . c o m public ReadablePeriod getRecoveryTimeout() { String timeoutStr = getScanValue().get("recovery").get("timeout").asString(); // Default to a 0-Day period if there's nothing to add if (timeoutStr == null) { return Days.days(0); } return ConfigMacroUtil.getTimePeriod(timeoutStr); }
From source file:org.forgerock.openidm.util.ConfigMacroUtil.java
License:Open Source License
/** * Defines the magnitudes that can be added to the timestamp * * @param token// ww w. j av a 2s. c o m * token of form "[number][magnitude]" (ex. "1d") * @return integer indicating the magnitude of the date for the calendar * system */ public static ReadablePeriod getTimePeriod(String token) { String valString = token.substring(0, token.length() - 1); int value = Integer.parseInt(valString); char mag = token.charAt(token.length() - 1); ReadablePeriod period; switch (mag) { case 's': period = Seconds.seconds(value); break; case 'm': period = Minutes.minutes(value); break; case 'h': period = Hours.hours(value); break; case 'd': period = Days.days(value); break; case 'M': period = Months.months(value); break; case 'y': period = Years.years(value); break; default: logger.warn("Invalid date magnitude: {}. Defaulting to seconds.", mag); period = Seconds.seconds(value); break; } return period; }
From source file:org.gnucash.android.model.Recurrence.java
License:Apache License
/** * Computes the number of occurrences of this recurrences between start and end date * <p>If there is no end date, it returns -1</p> * @return Number of occurrences, or -1 if there is no end date *///from www . ja va2s. c o m public int getCount() { if (mPeriodEnd == null) return -1; int multiple = mPeriodType.getMultiplier(); ReadablePeriod jodaPeriod; switch (mPeriodType) { case DAY: jodaPeriod = Days.days(multiple); break; case WEEK: jodaPeriod = Weeks.weeks(multiple); break; case MONTH: jodaPeriod = Months.months(multiple); break; case YEAR: jodaPeriod = Years.years(multiple); break; default: jodaPeriod = Months.months(multiple); } int count = 0; LocalDateTime startTime = new LocalDateTime(mPeriodStart.getTime()); while (startTime.toDateTime().getMillis() < mPeriodEnd.getTime()) { ++count; startTime = startTime.plus(jodaPeriod); } return count; /* //this solution does not use looping, but is not very accurate int multiplier = mPeriodType.getMultiplier(); LocalDateTime startDate = new LocalDateTime(mPeriodStart.getTime()); LocalDateTime endDate = new LocalDateTime(mPeriodEnd.getTime()); switch (mPeriodType){ case DAY: return Days.daysBetween(startDate, endDate).dividedBy(multiplier).getDays(); case WEEK: return Weeks.weeksBetween(startDate, endDate).dividedBy(multiplier).getWeeks(); case MONTH: return Months.monthsBetween(startDate, endDate).dividedBy(multiplier).getMonths(); case YEAR: return Years.yearsBetween(startDate, endDate).dividedBy(multiplier).getYears(); default: return -1; } */ }
From source file:org.mifos.calendar.DayOfWeek.java
License:Open Source License
public static Days mondayAsDay() { return Days.days(monday()); }
From source file:org.mifos.calendar.DayOfWeek.java
License:Open Source License
public static Days tuesdayAsDay() { return Days.days(tuesday()); }
From source file:org.mifos.calendar.DayOfWeek.java
License:Open Source License
public static Days wednesdayAsDay() { return Days.days(wednesday()); }
From source file:org.mifos.calendar.DayOfWeek.java
License:Open Source License
public static Days thursdayAsDay() { return Days.days(thursday()); }
From source file:org.mifos.calendar.DayOfWeek.java
License:Open Source License
public static Days fridayAsDay() { return Days.days(friday()); }
From source file:org.mifos.calendar.DayOfWeek.java
License:Open Source License
public static Days saturdayAsDay() { return Days.days(saturday()); }