/** * <p>Gets a formatter instance using the specified pattern in the * default locale.</p> * * @param pattern {@link java.text.SimpleDateFormat} compatible * pattern * @return a pattern based date/time formatter * @throws IllegalArgumentException if pattern is invalid */ public static FastDateFormat getInstance(String pattern) { return getInstance(pattern, null, null); }
/** * Adds a number of months to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addMonths(Date date, int amount) { return add(date, Calendar.MONTH, amount); }
/** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> * * @param date the date to format * @param pattern the pattern to use to format the date * @return the formatted date */ public static String formatUTC(Date date, String pattern) { return format(date, pattern, DateUtils.UTC_TIME_ZONE, null); }
/** * <p> * Gets a summary of the time that the stopwatch recorded as a string. * </p> * * <p> * The format used is ISO8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> * * @return the time as a String */ public String toString() { return DurationFormatUtils.formatDurationHMS(getTime()); }
/** * <p>Gets a formatter instance using the default pattern in the * default locale.</p> * * @return a date/time formatter */ public static FastDateFormat getInstance() { return getInstance(getDefaultPattern(), null, null); }
/** * <p> * Gets a summary of the split time that the stopwatch recorded as a string. * </p> * * <p> * The format used is ISO8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> * * @return the split time as a String * @since 2.1 */ public String toSplitString() { return DurationFormatUtils.formatDurationHMS(getSplitTime()); }
/** * {@inheritDoc} */ public int estimateLength() { return mRule.estimateLength(); }
/** * {@inheritDoc} */ public void appendTo(StringBuffer buffer, int value) { mRule.appendTo(buffer, value); } }
/** * <p>Formats a calendar into a specific pattern.</p> * * @param calendar the calendar to format * @param pattern the pattern to use to format the calendar * @return the formatted calendar * @see FastDateFormat#format(Calendar) * @since 2.4 */ public static String format(Calendar calendar, String pattern) { return format(calendar, pattern, null, null); }
/** * Adds a number of days to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addDays(Date date, int amount) { return add(date, Calendar.DAY_OF_MONTH, amount); }
/** * {@inheritDoc} */ public int estimateLength() { return mRule.estimateLength(); }
/** * {@inheritDoc} */ public void appendTo(StringBuffer buffer, int value) { mRule.appendTo(buffer, value); } }
/** * <p>Formats a date/time into a specific pattern in a time zone.</p> * * @param date the date to format * @param pattern the pattern to use to format the date * @param timeZone the time zone to use, may be <code>null</code> * @return the formatted date */ public static String format(Date date, String pattern, TimeZone timeZone) { return format(date, pattern, timeZone, null); }
/** * Adds a number of years to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addYears(Date date, int amount) { return add(date, Calendar.YEAR, amount); }
/** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> * * @param date the date to format * @param pattern the pattern to use to format the date * @param locale the locale to use, may be <code>null</code> * @return the formatted date */ public static String formatUTC(Date date, String pattern, Locale locale) { return format(date, pattern, DateUtils.UTC_TIME_ZONE, locale); }
/** * Adds a number of seconds to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addSeconds(Date date, int amount) { return add(date, Calendar.SECOND, amount); }
/** * <p>Formats a date/time into a specific pattern.</p> * * @param date the date to format * @param pattern the pattern to use to format the date * @return the formatted date */ public static String format(Date date, String pattern) { return format(date, pattern, null, null); }
/** * Adds a number of milliseconds to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addMilliseconds(Date date, int amount) { return add(date, Calendar.MILLISECOND, amount); }
/** * Adds a number of hours to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addHours(Date date, int amount) { return add(date, Calendar.HOUR_OF_DAY, amount); }
/** * Adds a number of weeks to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addWeeks(Date date, int amount) { return add(date, Calendar.WEEK_OF_YEAR, amount); }