/** * Converts the specified object to a date and formats it according to * the pattern or style returned by {@link #getFormat()}. * * @param obj the date object to be formatted * @return the specified date formatted as a string * @see #format(String format, Object obj, Locale locale, TimeZone timezone) * @since VelocityTools 1.1 */ public String format(Object obj) { return format(getFormat(), obj); }
/** * Converts the specified object to a date and returns * a formatted string representing that date in the locale * returned by {@link #getLocale()}. * * @param format the formatting instructions * @param obj the date object to be formatted * @return a formatted string for this locale representing the specified * date or <code>null</code> if the parameters are invalid * @see #format(String format, Object obj, Locale locale, TimeZone timezone) */ public String format(String format, Object obj) { return format(format, obj, getLocale()); }
/** * Converts the specified object to a date and returns * a formatted string representing that date in the specified * {@link Locale}. * * @param format the formatting instructions * @param obj the date object to be formatted * @param locale the locale to be used when formatting * @return the given date as a formatted string * @see #format(String format, Object obj, Locale locale, TimeZone timezone) */ public String format(String format, Object obj, Locale locale) { return format(format, obj, locale, getTimeZone()); }
/** * Returns the specified date as a string formatted according to the * specified date and/or time styles. * * @param dateStyle the style pattern for the date * @param timeStyle the style pattern for the time * @param obj the date to be formatted * @return a formatted representation of the given date * @see #format(String dateStyle, String timeStyle, Object obj, Locale locale, TimeZone timezone) * @since VelocityTools 1.1 */ public String format(String dateStyle, String timeStyle, Object obj) { return format(dateStyle, timeStyle, obj, getLocale()); }
/** * Returns the specified date as a string formatted according to the * specified {@link Locale} and date and/or time styles. * * @param dateStyle the style pattern for the date * @param timeStyle the style pattern for the time * @param obj the date to be formatted * @param locale the {@link Locale} to be used for formatting the date * @return a formatted representation of the given date * @see #format(String dateStyle, String timeStyle, Object obj, Locale locale, TimeZone timezone) * @since VelocityTools 1.1 */ public String format(String dateStyle, String timeStyle, Object obj, Locale locale) { return format(dateStyle, timeStyle, obj, locale, getTimeZone()); }
/** * Returns a formatted string representing the date returned by * {@link #getDate()}. In its default implementation, this method * allows you to retrieve the current date in standard formats by * simply doing things like <code>$date.medium</code> or * <code>$date.full</code>. If you want only the date or time portion * you can specify that along with the standard formats. (e.g. * <code>$date.medium_date</code> or <code>$date.short_time</code>) * More complex or custom formats can be retrieved * by using the full method syntax. (e.g. $date.get('E, MMMM d')) * * @param format the formatting instructions * @return a formatted representation of the date returned by * {@link #getDate()} * @see #format(String format, Object obj, Locale locale, TimeZone timezone) * @since VelocityTools 1.1 */ public String get(String format) { return format(format, getDate()); }
/** * @return the result of {@link #getDate()} formatted according to the result * of {@link #getFormat()}. * @see #format(String format, Object obj) */ public String toString() { return format(getFormat(), getDate()); }
/** * Returns a formatted string representing the date and/or time given by * {@link #getDate()} in standard, localized patterns. * * @param dateStyle the style pattern for the date * @param timeStyle the style pattern for the time * @return a formatted representation of the date returned by * {@link #getDate()} * @see DateFormat * @see #format(String dateStyle, String timeStyle, Object obj, Locale locale, TimeZone timezone) * @since VelocityTools 1.1 */ public String get(String dateStyle, String timeStyle) { return format(dateStyle, timeStyle, getDate(), getLocale()); }