/** * Gets the duration setting and converts it to days. * <p/> * The setting must be use one of the following conventions: * <ul> * <li>n MILLISECONDS * <li>n SECONDS * <li>n MINUTES * <li>n HOURS * <li>n DAYS * </ul> * * @param name * @param defaultValue in days * @return days */ public long getDurationInDays(String name, long defaultValue) { TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " DAYS"); long duration = getLong(name, defaultValue); return timeUnit.toDays(duration); }
/** * Gets the duration setting and converts it to milliseconds. * <p/> * The setting must be use one of the following conventions: * <ul> * <li>n MILLISECONDS * <li>n SECONDS * <li>n MINUTES * <li>n HOURS * <li>n DAYS * </ul> * * @param name * @param defaultValue in milliseconds * @return milliseconds */ public long getDurationInMilliseconds(String name, long defaultValue) { TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " MILLISECONDS"); long duration = getLong(name, defaultValue); return timeUnit.toMillis(duration); }
/** * Gets the duration setting and converts it to minutes. * <p/> * The setting must be use one of the following conventions: * <ul> * <li>n MILLISECONDS * <li>n SECONDS * <li>n MINUTES * <li>n HOURS * <li>n DAYS * </ul> * * @param name * @param defaultValue in minutes * @return minutes */ public long getDurationInMinutes(String name, long defaultValue) { TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " MINUTES"); long duration = getLong(name, defaultValue); return timeUnit.toMinutes(duration); }
/** * Gets the duration setting and converts it to seconds. * <p/> * The setting must be use one of the following conventions: * <ul> * <li>n MILLISECONDS * <li>n SECONDS * <li>n MINUTES * <li>n HOURS * <li>n DAYS * </ul> * * @param name * @param defaultValue in seconds * @return seconds */ public long getDurationInSeconds(String name, long defaultValue) { TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " SECONDS"); long duration = getLong(name, defaultValue); return timeUnit.toSeconds(duration); }
/** * Gets the duration setting and converts it to hours. * <p/> * The setting must be use one of the following conventions: * <ul> * <li>n MILLISECONDS * <li>n SECONDS * <li>n MINUTES * <li>n HOURS * <li>n DAYS * </ul> * * @param name * @param defaultValue in hours * @return hours */ public long getDurationInHours(String name, long defaultValue) { TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " HOURS"); long duration = getLong(name, defaultValue); return timeUnit.toHours(duration); }