FastDateFormat is a fast and thread-safe version of 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.
| Field Summary | |
|---|---|
| static int |
FULL locale dependent date or time style. |
| static int |
LONG locale dependent date or time style. |
| static int |
MEDIUM locale dependent date or time style. |
| static int |
SHORT locale dependent date or time style. |
| Constructor Summary |
|---|
|
Constructs a new FastDateFormat. |
| Method Summary | |
|---|---|
| protected StringBuffer |
Performs the formatting by applying the rules to the specified calendar. |
| boolean |
Compare two objects for equality. |
| StringBuffer |
Formats a |
| String |
Formats a millisecond |
| String |
Formats a |
| String |
Formats a |
| StringBuffer |
Formats a milliseond |
| StringBuffer |
Formats a |
| StringBuffer |
Formats a |
| static FastDateFormat |
Gets a date formatter instance using the specified style in the default time zone and locale. |
| static FastDateFormat |
Gets a date formatter instance using the specified style and locale in the default time zone. |
| static FastDateFormat |
Gets a date formatter instance using the specified style and time zone in the default locale. |
| static FastDateFormat |
Gets a date formatter instance using the specified style, time zone and locale. |
| static FastDateFormat |
Gets a date/time formatter instance using the specified style in the default time zone and locale. |
| static FastDateFormat |
Gets a date/time formatter instance using the specified style and locale in the default time zone. |
| static FastDateFormat |
Gets a date/time formatter instance using the specified style and time zone in the default locale. |
| static FastDateFormat |
Gets a date/time formatter instance using the specified style, time zone and locale. |
| static FastDateFormat |
Gets a formatter instance using the default pattern in the default locale. |
| static FastDateFormat |
Gets a formatter instance using the specified pattern in the default locale. |
| static FastDateFormat |
Gets a formatter instance using the specified pattern and time zone. |
| static FastDateFormat |
Gets a formatter instance using the specified pattern and locale. |
| static FastDateFormat |
Gets a formatter instance using the specified pattern, time zone and locale. |
| Locale |
Gets the locale used by this formatter. |
| int |
Gets an estimate for the maximum string length that the formatter will produce. |
| String |
Gets the pattern used by this formatter. |
| static FastDateFormat |
Gets a time formatter instance using the specified style in the default time zone and locale. |
| static FastDateFormat |
Gets a time formatter instance using the specified style and locale in the default time zone. |
| static FastDateFormat |
Gets a time formatter instance using the specified style and time zone in the default locale. |
| static FastDateFormat |
Gets a time formatter instance using the specified style, time zone and locale. |
| TimeZone |
Gets the time zone used by this formatter. |
| boolean |
Returns |
| int |
A suitable hashcode. |
| protected void |
Initialise the instance for first use. |
| Object |
Parsing not supported. |
| protected List |
Returns a list of Rules given a pattern. |
| protected String |
Performs the parsing of tokens. |
| protected FastDateFormat.NumberRule |
Gets an appropriate rule for the padding required. |
| String |
Gets a debugging string version of this formatter. |
| Methods inherited from java.textFormat |
|---|
| Methods inherited from java.langObject |
|---|
public static
int
FULL
public static
int
LONG
public static
int
MEDIUM
public static
int
SHORT
Performs the formatting by applying the rules to the specified calendar.
Compare two objects for equality.
Formats a Date, Calendar or
Long (milliseconds) object.
Formats a millisecond long value.
Formats a milliseond long value into the
supplied StringBuffer.
Formats a Date object into the
supplied StringBuffer.
Formats a Calendar object into the
supplied StringBuffer.
Gets a date formatter instance using the specified style in the default time zone and locale.
Gets a date formatter instance using the specified style and locale in the default time zone.
Gets a date formatter instance using the specified style and time zone in the default locale.
Gets a date formatter instance using the specified style, time zone and locale.
Gets a date/time formatter instance using the specified style in the default time zone and locale.
Gets a date/time formatter instance using the specified style and locale in the default time zone.
public static
FastDateFormat
getDateTimeInstance
(
int
dateStyle,
int
timeStyle,
TimeZone
timeZone
)
Gets a date/time formatter instance using the specified style and time zone in the default locale.
public static
FastDateFormat
getDateTimeInstance
(
int
dateStyle,
int
timeStyle,
TimeZone
timeZone,
Locale
locale
)
Gets a date/time formatter instance using the specified style, time zone and locale.
Gets a formatter instance using the default pattern in the default locale.
Gets a formatter instance using the specified pattern in the default locale.
Gets a formatter instance using the specified pattern and time zone.
Gets a formatter instance using the specified pattern and locale.
Gets a formatter instance using the specified pattern, time zone and locale.
Gets the locale used by this formatter.
public
int
getMaxLengthEstimate
(
)
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.
Gets the pattern used by this formatter.
Gets a time formatter instance using the specified style in the default time zone and locale.
Gets a time formatter instance using the specified style and locale in the default time zone.
Gets a time formatter instance using the specified style and time zone in the default locale.
Gets a time formatter instance using the specified style, time zone and locale.
Gets the time zone used by this formatter.
This zone is always used for Date formatting.
If a Calendar is passed in to be formatted, the
time zone on that may be used depending on
getTimeZoneOverridesCalendar() .
public
boolean
getTimeZoneOverridesCalendar
(
)
Returns true if the time zone of the
calendar overrides the time zone of the formatter.
public
int
hashCode
(
)
A suitable hashcode.
protected
void
init
(
)
Initialise the instance for first use.
Parsing not supported.
Returns a list of Rules given a pattern.
Gets an appropriate rule for the padding required.
Gets a debugging string version of this formatter.