public static final TimeZone getTimeZoneFromDateTime(String date) throws ParseException { return getTimeZoneFromDateTime(date, false); }
public static final TimeZone getTimeZoneFromDateTime(String date) throws ParseException { return getTimeZoneFromDateTime(date, false); }
/** * Returns the days between two dates. Positive values indicate that * the second date is after the first, and negative values indicate, well, * the opposite. * * @param isoEarly the "first date" in ISO DateTime Format * @param isoLate the "second date" in ISO Date Time format * @return the days between the two dates */ public static final long daysBetween(String isoEarly, String isoLate, boolean expanded) throws ParseException { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c1.setTimeZone(getTimeZoneFromDateTime(isoEarly, expanded)); c1.setTime(isoToDate(isoEarly, expanded)); c2.setTimeZone(getTimeZoneFromDateTime(isoLate, expanded)); c2.setTime(isoToDate(isoLate, expanded)); return millisToJulianDay(c2.getTime().getTime()) - millisToJulianDay(c1.getTime().getTime()); }
/** * Returns the days between two dates. Positive values indicate that * the second date is after the first, and negative values indicate, well, * the opposite. * * @param isoEarly the "first date" in ISO DateTime Format * @param isoLate the "second date" in ISO Date Time format * @return the days between the two dates */ public static final long daysBetween(String isoEarly, String isoLate, boolean expanded) throws ParseException { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c1.setTimeZone(getTimeZoneFromDateTime(isoEarly, expanded)); c1.setTime(isoToDate(isoEarly, expanded)); c2.setTimeZone(getTimeZoneFromDateTime(isoLate, expanded)); c2.setTime(isoToDate(isoLate, expanded)); return millisToJulianDay(c2.getTime().getTime()) - millisToJulianDay(c1.getTime().getTime()); }
/** * Time Field Rolling function. * Rolls (up/down) a single unit of time on the given time field. * * @param isoString * @param field the time field. * @param up Indicates if rolling up or rolling down the field value. * @param expanded use formating char's * @exception ParseException if an unknown field value is given. */ public static final String roll(String isoString, int field, boolean up, boolean expanded) throws ParseException { Calendar cal = GregorianCalendar.getInstance(getTimeZoneFromDateTime(isoString, expanded)); cal.setTime(isoToDate(isoString, expanded)); cal.roll(field, up); return dateToISO(cal.getTime(), expanded); }
/** * Time Field Rolling function. * Rolls (up/down) a single unit of time on the given time field. * * @param isoString * @param field the time field. * @param up Indicates if rolling up or rolling down the field value. * @param expanded use formating char's * @exception ParseException if an unknown field value is given. */ public static final String roll(String isoString, int field, boolean up, boolean expanded) throws ParseException { Calendar cal = GregorianCalendar.getInstance(getTimeZoneFromDateTime(isoString, expanded)); cal.setTime(isoToDate(isoString, expanded)); cal.roll(field, up); return dateToISO(cal.getTime(), expanded); }