/** * non-expanded * * @param date * @return ISO Date String */ public static final String dateToISO(Date date) { return dateToISO(date, false); }
/** * non-expanded * * @param date * @return ISO Date String */ public static final String dateToISO(Date date) { return dateToISO(date, false); }
/** * Date Arithmetic function. * Adds the specified (signed) amount of time to the given time field, * based on the GregorianCalendar's rules. * @param isoString * @param field * @param amount * @param expanded use formating char's * @return ISO 8601 Date String * @throws ParseException */ public static final String add(String isoString, int field, int amount, boolean expanded) throws ParseException { Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); cal.setTime(isoToDate(isoString, expanded)); cal.add(field, amount); return dateToISO(cal.getTime(), expanded); }
/** * Date Arithmetic function. * Adds the specified (signed) amount of time to the given time field, * based on the GregorianCalendar's rules. * @param isoString * @param field * @param amount * @param expanded use formating char's * @return ISO 8601 Date String * @throws ParseException */ public static final String add(String isoString, int field, int amount, boolean expanded) throws ParseException { Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); cal.setTime(isoToDate(isoString, expanded)); cal.add(field, amount); 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); }
/** * 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); }