| java.lang.Object java.text.Format org.apache.commons.lang.time.FastDateFormat
FastDateFormat | public class FastDateFormat extends Format (Code) | | FastDateFormat is a fast and thread-safe version of
java.text.SimpleDateFormat .
This class can be used as a direct replacement to
SimpleDateFormat in most formatting situations.
This class is especially useful in multi-threaded server environments.
SimpleDateFormat is not thread-safe in any JDK version,
nor will it be as Sun have closed the bug/RFE.
Only formatting is supported, but all patterns are compatible with
SimpleDateFormat (except time zones - see below).
Java 1.4 introduced a new pattern letter, 'Z' , to represent
time zones in RFC822 format (eg. +0800 or -1100 ).
This pattern letter can be used here (on all JDK versions).
In addition, the pattern 'ZZ' has been made to represent
ISO8601 full format time zones (eg. +08:00 or -11:00 ).
This introduces a minor incompatibility with Java 1.4, but at a gain of
useful functionality.
author: TeaTrove project author: Brian S O'Neill author: Sean Schofield author: Gary Gregory author: Stephen Colebourne author: Nikolay Metchev since: 2.0 version: $Id: FastDateFormat.java 504349 2007-02-06 22:44:33Z bayard $ |
Field Summary | |
final public static int | FULL FULL locale dependent date or time style. | final public static int | LONG LONG locale dependent date or time style. | final public static int | MEDIUM MEDIUM locale dependent date or time style. | final public static int | SHORT SHORT locale dependent date or time style. |
Method Summary | |
protected StringBuffer | applyRules(Calendar calendar, StringBuffer buf) | public boolean | equals(Object obj) | public StringBuffer | format(Object obj, StringBuffer toAppendTo, FieldPosition pos) | public String | format(long millis) | public String | format(Date date) | public String | format(Calendar calendar) | public StringBuffer | format(long millis, StringBuffer buf) | public StringBuffer | format(Date date, StringBuffer buf) | public StringBuffer | format(Calendar calendar, StringBuffer buf) | public static FastDateFormat | getDateInstance(int style) | public static FastDateFormat | getDateInstance(int style, Locale locale) | public static FastDateFormat | getDateInstance(int style, TimeZone timeZone) | public static synchronized FastDateFormat | getDateInstance(int style, TimeZone timeZone, Locale locale) | public static FastDateFormat | getDateTimeInstance(int dateStyle, int timeStyle) | public static FastDateFormat | getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) | public static FastDateFormat | getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone) | public static synchronized FastDateFormat | getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone, Locale locale) | public static FastDateFormat | getInstance() | public static FastDateFormat | getInstance(String pattern) | public static FastDateFormat | getInstance(String pattern, TimeZone timeZone) | public static FastDateFormat | getInstance(String pattern, Locale locale) | public static synchronized FastDateFormat | getInstance(String pattern, TimeZone timeZone, Locale locale) | public Locale | getLocale() | public int | getMaxLengthEstimate() | public String | getPattern() | public static FastDateFormat | getTimeInstance(int style) | public static FastDateFormat | getTimeInstance(int style, Locale locale) | public static FastDateFormat | getTimeInstance(int style, TimeZone timeZone) | public static synchronized FastDateFormat | getTimeInstance(int style, TimeZone timeZone, Locale locale) | public TimeZone | getTimeZone() Gets the time zone used by this formatter.
This zone is always used for Date formatting. | static synchronized String | getTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Locale locale) | public boolean | getTimeZoneOverridesCalendar() | public int | hashCode() | protected void | init() | public Object | parseObject(String source, ParsePosition pos) | protected List | parsePattern() | protected String | parseToken(String pattern, int[] indexRef) | protected NumberRule | selectNumberRule(int field, int padding) | public String | toString() |
FULL | final public static int FULL(Code) | | FULL locale dependent date or time style.
|
LONG | final public static int LONG(Code) | | LONG locale dependent date or time style.
|
MEDIUM | final public static int MEDIUM(Code) | | MEDIUM locale dependent date or time style.
|
SHORT | final public static int SHORT(Code) | | SHORT locale dependent date or time style.
|
FastDateFormat | protected FastDateFormat(String pattern, TimeZone timeZone, Locale locale)(Code) | | Constructs a new FastDateFormat.
Parameters: pattern - java.text.SimpleDateFormat compatiblepattern Parameters: timeZone - time zone to use, null means usedefault for Date and value within forCalendar Parameters: locale - locale, null means use systemdefault throws: IllegalArgumentException - if pattern is invalid ornull |
applyRules | protected StringBuffer applyRules(Calendar calendar, StringBuffer buf)(Code) | | Performs the formatting by applying the rules to the
specified calendar.
Parameters: calendar - the calendar to format Parameters: buf - the buffer to format into the specified string buffer |
equals | public boolean equals(Object obj)(Code) | | Compares two objects for equality.
Parameters: obj - the object to compare to true if equal |
format | public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)(Code) | | Formats a Date , Calendar or
Long (milliseconds) object.
Parameters: obj - the object to format Parameters: toAppendTo - the buffer to append to Parameters: pos - the position - ignored the buffer passed in |
format | public String format(long millis)(Code) | | Formats a millisecond long value.
Parameters: millis - the millisecond value to format the formatted string since: 2.1 |
format | public String format(Date date)(Code) | | Formats a Date object.
Parameters: date - the date to format the formatted string |
format | public String format(Calendar calendar)(Code) | | Formats a Calendar object.
Parameters: calendar - the calendar to format the formatted string |
format | public StringBuffer format(long millis, StringBuffer buf)(Code) | | Formats a milliseond long value into the
supplied StringBuffer .
Parameters: millis - the millisecond value to format Parameters: buf - the buffer to format into the specified string buffer since: 2.1 |
format | public StringBuffer format(Date date, StringBuffer buf)(Code) | | Formats a Date object into the
supplied StringBuffer .
Parameters: date - the date to format Parameters: buf - the buffer to format into the specified string buffer |
format | public StringBuffer format(Calendar calendar, StringBuffer buf)(Code) | | Formats a Calendar object into the
supplied StringBuffer .
Parameters: calendar - the calendar to format Parameters: buf - the buffer to format into the specified string buffer |
getDateInstance | public static FastDateFormat getDateInstance(int style)(Code) | | Gets a date formatter instance using the specified style in the
default time zone and locale.
Parameters: style - date style: FULL, LONG, MEDIUM, or SHORT a localized standard date formatter throws: IllegalArgumentException - if the Locale has no datepattern defined since: 2.1 |
getDateInstance | public static FastDateFormat getDateInstance(int style, Locale locale)(Code) | | Gets a date formatter instance using the specified style and
locale in the default time zone.
Parameters: style - date style: FULL, LONG, MEDIUM, or SHORT Parameters: locale - optional locale, overrides system locale a localized standard date formatter throws: IllegalArgumentException - if the Locale has no datepattern defined since: 2.1 |
getDateInstance | public static FastDateFormat getDateInstance(int style, TimeZone timeZone)(Code) | | Gets a date formatter instance using the specified style and
time zone in the default locale.
Parameters: style - date style: FULL, LONG, MEDIUM, or SHORT Parameters: timeZone - optional time zone, overrides time zone offormatted date a localized standard date formatter throws: IllegalArgumentException - if the Locale has no datepattern defined since: 2.1 |
getDateInstance | public static synchronized FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale)(Code) | | Gets a date formatter instance using the specified style, time
zone and locale.
Parameters: style - date style: FULL, LONG, MEDIUM, or SHORT Parameters: timeZone - optional time zone, overrides time zone offormatted date Parameters: locale - optional locale, overrides system locale a localized standard date formatter throws: IllegalArgumentException - if the Locale has no datepattern defined |
getDateTimeInstance | public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle)(Code) | | Gets a date/time formatter instance using the specified style
in the default time zone and locale.
Parameters: dateStyle - date style: FULL, LONG, MEDIUM, or SHORT Parameters: timeStyle - time style: FULL, LONG, MEDIUM, or SHORT a localized standard date/time formatter throws: IllegalArgumentException - if the Locale has no date/timepattern defined since: 2.1 |
getDateTimeInstance | public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale)(Code) | | Gets a date/time formatter instance using the specified style and
locale in the default time zone.
Parameters: dateStyle - date style: FULL, LONG, MEDIUM, or SHORT Parameters: timeStyle - time style: FULL, LONG, MEDIUM, or SHORT Parameters: locale - optional locale, overrides system locale a localized standard date/time formatter throws: IllegalArgumentException - if the Locale has no date/timepattern defined since: 2.1 |
getDateTimeInstance | public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone)(Code) | | Gets a date/time formatter instance using the specified style and
time zone in the default locale.
Parameters: dateStyle - date style: FULL, LONG, MEDIUM, or SHORT Parameters: timeStyle - time style: FULL, LONG, MEDIUM, or SHORT Parameters: timeZone - optional time zone, overrides time zone offormatted date a localized standard date/time formatter throws: IllegalArgumentException - if the Locale has no date/timepattern defined since: 2.1 |
getDateTimeInstance | public static synchronized FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone, Locale locale)(Code) | | Gets a date/time formatter instance using the specified style,
time zone and locale.
Parameters: dateStyle - date style: FULL, LONG, MEDIUM, or SHORT Parameters: timeStyle - time style: FULL, LONG, MEDIUM, or SHORT Parameters: timeZone - optional time zone, overrides time zone offormatted date Parameters: locale - optional locale, overrides system locale a localized standard date/time formatter throws: IllegalArgumentException - if the Locale has no date/timepattern defined |
getInstance | public static FastDateFormat getInstance()(Code) | | Gets a formatter instance using the default pattern in the
default locale.
a date/time formatter |
getInstance | public static synchronized FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale)(Code) | | Gets a formatter instance using the specified pattern, time zone
and locale.
Parameters: pattern - java.text.SimpleDateFormat compatiblepattern Parameters: timeZone - optional time zone, overrides time zone offormatted date Parameters: locale - optional locale, overrides system locale a pattern based date/time formatter throws: IllegalArgumentException - if pattern is invalidor null |
getLocale | public Locale getLocale()(Code) | | Gets the locale used by this formatter.
the locale |
getMaxLengthEstimate | public int getMaxLengthEstimate()(Code) | | Gets an estimate for the maximum string length that the
formatter will produce.
The actual formatted length will almost always be less than or
equal to this amount.
the maximum formatted length |
getTimeInstance | public static FastDateFormat getTimeInstance(int style)(Code) | | Gets a time formatter instance using the specified style in the
default time zone and locale.
Parameters: style - time style: FULL, LONG, MEDIUM, or SHORT a localized standard time formatter throws: IllegalArgumentException - if the Locale has no timepattern defined since: 2.1 |
getTimeInstance | public static FastDateFormat getTimeInstance(int style, Locale locale)(Code) | | Gets a time formatter instance using the specified style and
locale in the default time zone.
Parameters: style - time style: FULL, LONG, MEDIUM, or SHORT Parameters: locale - optional locale, overrides system locale a localized standard time formatter throws: IllegalArgumentException - if the Locale has no timepattern defined since: 2.1 |
getTimeInstance | public static FastDateFormat getTimeInstance(int style, TimeZone timeZone)(Code) | | Gets a time formatter instance using the specified style and
time zone in the default locale.
Parameters: style - time style: FULL, LONG, MEDIUM, or SHORT Parameters: timeZone - optional time zone, overrides time zone offormatted time a localized standard time formatter throws: IllegalArgumentException - if the Locale has no timepattern defined since: 2.1 |
getTimeInstance | public static synchronized FastDateFormat getTimeInstance(int style, TimeZone timeZone, Locale locale)(Code) | | Gets a time formatter instance using the specified style, time
zone and locale.
Parameters: style - time style: FULL, LONG, MEDIUM, or SHORT Parameters: timeZone - optional time zone, overrides time zone offormatted time Parameters: locale - optional locale, overrides system locale a localized standard time formatter throws: IllegalArgumentException - if the Locale has no timepattern defined |
getTimeZoneDisplay | static synchronized String getTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Locale locale)(Code) | | Gets the time zone display name, using a cache for performance.
Parameters: tz - the zone to query Parameters: daylight - true if daylight savings Parameters: style - the style to use TimeZone.LONG or TimeZone.SHORT Parameters: locale - the locale to use the textual name of the time zone |
getTimeZoneOverridesCalendar | public boolean getTimeZoneOverridesCalendar()(Code) | | Returns true if the time zone of the
calendar overrides the time zone of the formatter.
true if time zone of formatteroverridden for calendars |
hashCode | public int hashCode()(Code) | | Returns a hashcode compatible with equals.
a hashcode compatible with equals |
init | protected void init()(Code) | | Initializes the instance for first use.
|
parseObject | public Object parseObject(String source, ParsePosition pos)(Code) | | Parsing is not supported.
Parameters: source - the string to parse Parameters: pos - the parsing position null as not supported |
parseToken | protected String parseToken(String pattern, int[] indexRef)(Code) | | Performs the parsing of tokens.
Parameters: pattern - the pattern Parameters: indexRef - index references parsed token |
selectNumberRule | protected NumberRule selectNumberRule(int field, int padding)(Code) | | Gets an appropriate rule for the padding required.
Parameters: field - the field to get a rule for Parameters: padding - the padding required a new rule with the correct padding |
toString | public String toString()(Code) | | Gets a debugging string version of this formatter.
a debugging string |
|
|