Package org.jivesoftware.util
Class FastDateFormat
- java.lang.Object
-
- org.jivesoftware.util.FastDateFormat
-
public class FastDateFormat extends Object
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(Calendar calendar)StringBufferformat(Calendar calendar, StringBuffer buf)Stringformat(Date date)StringBufferformat(Date date, StringBuffer buf)static FastDateFormatgetDateInstance(Object style, TimeZone timeZone, Locale locale)static FastDateFormatgetDateTimeInstance(Object dateStyle, Object timeStyle, TimeZone timeZone, Locale locale)static FastDateFormatgetInstance()static 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)LocalegetLocale()Return the locale used by this formatter, or null if locale of formatted dates is used instead.intgetMaxLengthEstimate()Returns an estimate for the maximum length date that this date formatter will produce.StringgetPattern()static FastDateFormatgetTimeInstance(Object style, TimeZone timeZone, Locale locale)TimeZonegetTimeZone()Returns the time zone used by this formatter, or null if time zone of formatted dates is used instead.
-
-
-
Method Detail
-
getInstance
public static FastDateFormat getInstance()
-
getInstance
public static FastDateFormat getInstance(String pattern) throws IllegalArgumentException
- Parameters:
pattern-SimpleDateFormatcompatible pattern- Returns:
- date format with specified 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- Returns:
- date format with specified pattern and timezone.
- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, Locale locale) throws IllegalArgumentException
- Parameters:
pattern-SimpleDateFormatcompatible patternlocale- optional locale, overrides system locale- Returns:
- date format with specified pattern and 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- Returns:
- date format with specified pattern and format symbols.
- 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- Returns:
- date format with specified pattern, timezone and 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- Returns:
- date format with specified pattern, timezone, locale and format symbols.
- 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- Returns:
- date format with specified style, timezone and 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- Returns:
- date format with specified style, timezone and 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- Returns:
- date format with specified date, time styles, timezone and locale.
- Throws:
IllegalArgumentException
-
format
public StringBuffer format(Date date, StringBuffer buf)
-
format
public StringBuffer format(Calendar calendar, StringBuffer buf)
-
getPattern
public String getPattern()
-
getTimeZone
public TimeZone getTimeZone()
Returns the time zone used by this formatter, or null if time zone of formatted dates is used instead.- Returns:
- time zone.
-
getLocale
public Locale getLocale()
Return the locale used by this formatter, or null if locale of formatted dates is used instead.- Returns:
- locale.
-
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.- Returns:
- maximum length date estimate.
-
-