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
-
-
-
Method Detail
-
getInstance
public static FastDateFormat getInstance()
-
getInstance
public static FastDateFormat getInstance(String pattern) throws IllegalArgumentException
- Parameters:
pattern
-SimpleDateFormat
compatible pattern- Returns:
- the fast date format
- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone) throws IllegalArgumentException
- Parameters:
pattern
-SimpleDateFormat
compatible patterntimeZone
- optional time zone, overrides time zone of formatted date- Returns:
- the fast date format
- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, Locale locale) throws IllegalArgumentException
- Parameters:
pattern
-SimpleDateFormat
compatible patternlocale
- optional locale, overrides system locale- Returns:
- the fast date format
- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, DateFormatSymbols symbols) throws IllegalArgumentException
- Parameters:
pattern
-SimpleDateFormat
compatible patternsymbols
- optional date format symbols, overrides symbols for system locale- Returns:
- the fast date format
- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale) throws IllegalArgumentException
- Parameters:
pattern
-SimpleDateFormat
compatible patterntimeZone
- optional time zone, overrides time zone of formatted datelocale
- optional locale, overrides system locale- Returns:
- the fast date format
- Throws:
IllegalArgumentException
-
getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale, DateFormatSymbols symbols) throws IllegalArgumentException
- Parameters:
pattern
-SimpleDateFormat
compatible 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:
- the fast date format
- 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:
- the fast date format
- 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:
- the fast date format
- 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:
- the fast date format
- 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:
- the time zone
-
getLocale
public Locale 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.- Returns:
- an estimate of the maximum length
-
-