Package org.jivesoftware.util
Class FastDateFormat
java.lang.Object
org.jivesoftware.util.FastDateFormat
Similar to SimpleDateFormat, but faster and thread-safe.
Only formatting is supported, but all patterns are compatible with
SimpleDateFormat.
Note, this class is from the open source Tea project (http://sourceforge.net/projects/teatrove/).
- Author:
- Brian S O'Neill
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionformat(Calendar calendar, StringBuffer buf) format(Date date, StringBuffer buf) static FastDateFormatgetDateInstance(Object style, TimeZone timeZone, Locale locale) static FastDateFormatgetDateTimeInstance(Object dateStyle, Object timeStyle, TimeZone timeZone, Locale locale) static FastDateFormatstatic FastDateFormatgetInstance(String pattern) static FastDateFormatgetInstance(String pattern, DateFormatSymbols symbols) static FastDateFormatgetInstance(String pattern, Locale locale) static FastDateFormatgetInstance(String pattern, TimeZone timeZone) static FastDateFormatgetInstance(String pattern, TimeZone timeZone, Locale locale) static FastDateFormatgetInstance(String pattern, TimeZone timeZone, Locale locale, DateFormatSymbols symbols) intReturns an estimate for the maximum length date that this date formatter will produce.static FastDateFormatgetTimeInstance(Object style, TimeZone timeZone, Locale locale) Returns the time zone used by this formatter, or null if time zone of formatted dates is used instead.
-
Field Details
-
FULL
Style pattern -
LONG
Style pattern -
MEDIUM
Style pattern -
SHORT
Style pattern
-
-
Method Details
-
getInstance
-
getInstance
- Parameters:
pattern-SimpleDateFormatcompatible pattern- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone) throws IllegalArgumentException - Parameters:
pattern-SimpleDateFormatcompatible patterntimeZone- optional time zone, overrides time zone of formatted date- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, Locale locale) throws IllegalArgumentException - Parameters:
pattern-SimpleDateFormatcompatible patternlocale- optional locale, overrides system locale- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, DateFormatSymbols symbols) throws IllegalArgumentException - Parameters:
pattern-SimpleDateFormatcompatible patternsymbols- optional date format symbols, overrides symbols for system locale- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale) throws IllegalArgumentException - Parameters:
pattern-SimpleDateFormatcompatible patterntimeZone- optional time zone, overrides time zone of formatted datelocale- optional locale, overrides system locale- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale, DateFormatSymbols symbols) throws IllegalArgumentException - Parameters:
pattern-SimpleDateFormatcompatible patterntimeZone- optional time zone, overrides time zone of formatted datelocale- optional locale, overrides system localesymbols- optional date format symbols, overrides symbols for provided locale- Throws:
IllegalArgumentException
-
getDateInstance
public static FastDateFormat getDateInstance(Object style, TimeZone timeZone, Locale locale) throws IllegalArgumentException - Parameters:
style- date style: FULL, LONG, MEDIUM, or SHORTtimeZone- optional time zone, overrides time zone of formatted datelocale- optional locale, overrides system locale- Throws:
IllegalArgumentException
-
getTimeInstance
public static FastDateFormat getTimeInstance(Object style, TimeZone timeZone, Locale locale) throws IllegalArgumentException - Parameters:
style- time style: FULL, LONG, MEDIUM, or SHORTtimeZone- optional time zone, overrides time zone of formatted datelocale- optional locale, overrides system locale- Throws:
IllegalArgumentException
-
getDateTimeInstance
public static FastDateFormat getDateTimeInstance(Object dateStyle, Object timeStyle, TimeZone timeZone, Locale locale) throws IllegalArgumentException - Parameters:
dateStyle- date style: FULL, LONG, MEDIUM, or SHORTtimeStyle- time style: FULL, LONG, MEDIUM, or SHORTtimeZone- optional time zone, overrides time zone of formatted datelocale- optional locale, overrides system locale- Throws:
IllegalArgumentException
-
format
-
format
-
format
-
format
-
getPattern
-
getTimeZone
Returns the time zone used by this formatter, or null if time zone of formatted dates is used instead. -
getLocale
-
getMaxLengthEstimate
public int getMaxLengthEstimate()Returns an estimate for the maximum length date that this date formatter will produce. The actual formatted length will almost always be less than or equal to this amount.
-