/** * Get the duration in seconds -+ * @return the duration in seconds * @deprecated dont use because these are fixed length and thus approximate. */ public double getValueInMillisecs() { if (field == CalendarPeriod.Field.Month) return 30.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value; else if (field == CalendarPeriod.Field.Year) return 365.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value; else return millisecs(); }
/** * Get the duration in milliseconds -+ * @return the duration in seconds * @deprecated dont use because these are fixed length and thus approximate. */ public double getValueInMillisecs() { if (field == CalendarPeriod.Field.Month) return 30.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value; else if (field == CalendarPeriod.Field.Year) return 365.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value; else return millisecs(); }
/** * Get the duration in seconds -+ * * @return the duration in seconds * @deprecated dont use because these are fixed length and thus approximate. */ public double getValueInMillisecs() { if (field == CalendarPeriod.Field.Month) return 30.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value; else if (field == CalendarPeriod.Field.Year) return 365.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value; else return millisecs(); }
/** * Get the conversion factor of the other CalendarPeriod to this one * @param from convert from this * @return conversion factor, so that getConvertFactor(from) * from = this */ public double getConvertFactor(CalendarPeriod from) { if (field == CalendarPeriod.Field.Month || field == CalendarPeriod.Field.Year) { log.warn(" CalendarDate.convert on Month or Year"); } return (double)from.millisecs() / millisecs(); }
/** * Get the conversion factor of the other CalendarPeriod to this one * @param from convert from this * @return conversion factor, so that getConvertFactor(from) * from = this */ public double getConvertFactor(CalendarPeriod from) { if (field == CalendarPeriod.Field.Month || field == CalendarPeriod.Field.Year) { log.warn(" CalendarDate.convert on Month or Year"); } return (double) from.millisecs() / millisecs(); }
/** * Get the conversion factor of the other CalendarPeriod to this one * @param from convert from this * @return conversion factor, so that getConvertFactor(from) * from = this */ public double getConvertFactor(CalendarPeriod from) { if (field == CalendarPeriod.Field.Month || field == CalendarPeriod.Field.Year) { log.warn(" CalendarDate.convert on Month or Year"); } return (double)from.millisecs() / millisecs(); }
/** * Subtract two dates, return difference in units of this period. * If not even, will round down and log a warning * @param start start date * @param end end date * @return difference in units of this period */ public int subtract(CalendarDate start, CalendarDate end) { long diff = end.getDifferenceInMsecs(start); int thislen = millisecs(); if ((diff % thislen != 0)) log.warn("roundoff error"); return (int) (diff / thislen); }
/** * Subtract two dates, return difference in units of this period. * If not even, will round down and log a warning * @param start start date * @param end end date * @return difference in units of this period */ public int subtract(CalendarDate start, CalendarDate end) { long diff = end.getDifferenceInMsecs(start); int thislen = millisecs(); if ((diff % thislen != 0)) log.warn("roundoff error"); return (int) (diff / thislen); }
/** * Subtract two dates, return difference in units of this period. * If not even, will round down and log a warning * @param start start date * @param end end date * @return difference in units of this period */ public int subtract(CalendarDate start, CalendarDate end) { long diff = end.getDifferenceInMsecs(start); int thislen = millisecs(); if ((diff % thislen != 0)) log.warn("roundoff error"); return (int) (diff / thislen); }