/** * non-expanded * * @param dateString * @return ISO java.util.Date * @throws ParseException */ public static final Date isoToDate(String dateString) throws ParseException { return isoToDate(dateString, false); }
/** * non-expanded * * @param dateString * @return ISO java.util.Date * @throws ParseException */ public static final Date isoToDate(String dateString) throws ParseException { return isoToDate(dateString, false); }
/** * * @param isoString * @param expanded * @return True id leap year * @throws ParseException */ public static final boolean isLeapYear(String isoString, boolean expanded) throws ParseException { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(isoToDate(isoString, expanded)); return cal.isLeapYear(cal.get(Calendar.YEAR)); }
/** * * @param isoString * @param expanded * @return True id leap year * @throws ParseException */ public static final boolean isLeapYear(String isoString, boolean expanded) throws ParseException { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(isoToDate(isoString, expanded)); return cal.isLeapYear(cal.get(Calendar.YEAR)); }
/** * 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); }
/** * 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); }