org.jivesoftware.util
Class FastDateFormat

java.lang.Object
  extended by org.jivesoftware.util.FastDateFormat

public class FastDateFormat
extends java.lang.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

Field Summary
static java.lang.Object FULL
          Style pattern
static java.lang.Object LONG
          Style pattern
static java.lang.Object MEDIUM
          Style pattern
static java.lang.Object SHORT
          Style pattern
 
Method Summary
 java.lang.String format(java.util.Calendar calendar)
           
 java.lang.StringBuffer format(java.util.Calendar calendar, java.lang.StringBuffer buf)
           
 java.lang.String format(java.util.Date date)
           
 java.lang.StringBuffer format(java.util.Date date, java.lang.StringBuffer buf)
           
static FastDateFormat getDateInstance(java.lang.Object style, java.util.TimeZone timeZone, java.util.Locale locale)
           
static FastDateFormat getDateTimeInstance(java.lang.Object dateStyle, java.lang.Object timeStyle, java.util.TimeZone timeZone, java.util.Locale locale)
           
static FastDateFormat getInstance()
           
static FastDateFormat getInstance(java.lang.String pattern)
           
static FastDateFormat getInstance(java.lang.String pattern, java.text.DateFormatSymbols symbols)
           
static FastDateFormat getInstance(java.lang.String pattern, java.util.Locale locale)
           
static FastDateFormat getInstance(java.lang.String pattern, java.util.TimeZone timeZone)
           
static FastDateFormat getInstance(java.lang.String pattern, java.util.TimeZone timeZone, java.util.Locale locale)
           
static FastDateFormat getInstance(java.lang.String pattern, java.util.TimeZone timeZone, java.util.Locale locale, java.text.DateFormatSymbols symbols)
           
 java.util.Locale getLocale()
           
 int getMaxLengthEstimate()
          Returns an estimate for the maximum length date that this date formatter will produce.
 java.lang.String getPattern()
           
static FastDateFormat getTimeInstance(java.lang.Object style, java.util.TimeZone timeZone, java.util.Locale locale)
           
 java.util.TimeZone getTimeZone()
          Returns the time zone used by this formatter, or null if time zone of formatted dates is used instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FULL

public static final java.lang.Object FULL
Style pattern


LONG

public static final java.lang.Object LONG
Style pattern


MEDIUM

public static final java.lang.Object MEDIUM
Style pattern


SHORT

public static final java.lang.Object SHORT
Style pattern

Method Detail

getInstance

public static FastDateFormat getInstance()

getInstance

public static FastDateFormat getInstance(java.lang.String pattern)
                                  throws java.lang.IllegalArgumentException
Parameters:
pattern - SimpleDateFormat compatible pattern
Throws:
java.lang.IllegalArgumentException

getInstance

public static FastDateFormat getInstance(java.lang.String pattern,
                                         java.util.TimeZone timeZone)
                                  throws java.lang.IllegalArgumentException
Parameters:
pattern - SimpleDateFormat compatible pattern
timeZone - optional time zone, overrides time zone of formatted date
Throws:
java.lang.IllegalArgumentException

getInstance

public static FastDateFormat getInstance(java.lang.String pattern,
                                         java.util.Locale locale)
                                  throws java.lang.IllegalArgumentException
Parameters:
pattern - SimpleDateFormat compatible pattern
locale - optional locale, overrides system locale
Throws:
java.lang.IllegalArgumentException

getInstance

public static FastDateFormat getInstance(java.lang.String pattern,
                                         java.text.DateFormatSymbols symbols)
                                  throws java.lang.IllegalArgumentException
Parameters:
pattern - SimpleDateFormat compatible pattern
symbols - optional date format symbols, overrides symbols for system locale
Throws:
java.lang.IllegalArgumentException

getInstance

public static FastDateFormat getInstance(java.lang.String pattern,
                                         java.util.TimeZone timeZone,
                                         java.util.Locale locale)
                                  throws java.lang.IllegalArgumentException
Parameters:
pattern - SimpleDateFormat compatible pattern
timeZone - optional time zone, overrides time zone of formatted date
locale - optional locale, overrides system locale
Throws:
java.lang.IllegalArgumentException

getInstance

public static FastDateFormat getInstance(java.lang.String pattern,
                                         java.util.TimeZone timeZone,
                                         java.util.Locale locale,
                                         java.text.DateFormatSymbols symbols)
                                  throws java.lang.IllegalArgumentException
Parameters:
pattern - SimpleDateFormat compatible pattern
timeZone - optional time zone, overrides time zone of formatted date
locale - optional locale, overrides system locale
symbols - optional date format symbols, overrides symbols for provided locale
Throws:
java.lang.IllegalArgumentException

getDateInstance

public static FastDateFormat getDateInstance(java.lang.Object style,
                                             java.util.TimeZone timeZone,
                                             java.util.Locale locale)
                                      throws java.lang.IllegalArgumentException
Parameters:
style - date style: FULL, LONG, MEDIUM, or SHORT
timeZone - optional time zone, overrides time zone of formatted date
locale - optional locale, overrides system locale
Throws:
java.lang.IllegalArgumentException

getTimeInstance

public static FastDateFormat getTimeInstance(java.lang.Object style,
                                             java.util.TimeZone timeZone,
                                             java.util.Locale locale)
                                      throws java.lang.IllegalArgumentException
Parameters:
style - time style: FULL, LONG, MEDIUM, or SHORT
timeZone - optional time zone, overrides time zone of formatted date
locale - optional locale, overrides system locale
Throws:
java.lang.IllegalArgumentException

getDateTimeInstance

public static FastDateFormat getDateTimeInstance(java.lang.Object dateStyle,
                                                 java.lang.Object timeStyle,
                                                 java.util.TimeZone timeZone,
                                                 java.util.Locale locale)
                                          throws java.lang.IllegalArgumentException
Parameters:
dateStyle - date style: FULL, LONG, MEDIUM, or SHORT
timeStyle - time style: FULL, LONG, MEDIUM, or SHORT
timeZone - optional time zone, overrides time zone of formatted date
locale - optional locale, overrides system locale
Throws:
java.lang.IllegalArgumentException

format

public java.lang.String format(java.util.Date date)

format

public java.lang.String format(java.util.Calendar calendar)

format

public java.lang.StringBuffer format(java.util.Date date,
                                     java.lang.StringBuffer buf)

format

public java.lang.StringBuffer format(java.util.Calendar calendar,
                                     java.lang.StringBuffer buf)

getPattern

public java.lang.String getPattern()

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone used by this formatter, or null if time zone of formatted dates is used instead.


getLocale

public java.util.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.



Copyright © 2009 Ignite Realtime. All Rights Reserved.