Save This Page
Home » commons-lang-2.4-src » org.apache.commons » lang » time » [javadoc | source]
org.apache.commons.lang.time
public class: FastDateFormat [javadoc | source]
java.lang.Object
   java.text.Format
      org.apache.commons.lang.time.FastDateFormat

All Implemented Interfaces:
    Serializable, Cloneable

FastDateFormat is a fast and thread-safe version of java.text.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
public static final  int FULL    FULL locale dependent date or time style. 
public static final  int LONG    LONG locale dependent date or time style. 
public static final  int MEDIUM    MEDIUM locale dependent date or time style. 
public static final  int SHORT    SHORT locale dependent date or time style. 
Constructor:
 protected FastDateFormat(String pattern,
    TimeZone timeZone,
    Locale locale) 

    Constructs a new FastDateFormat.

    Parameters:
    pattern - java.text.SimpleDateFormat compatible pattern
    timeZone - time zone to use, null means use default for Date and value within for Calendar
    locale - locale, null means use system default
    Throws:
    IllegalArgumentException - if pattern is invalid or null
Method from org.apache.commons.lang.time.FastDateFormat Summary:
applyRules,   equals,   format,   format,   format,   format,   format,   format,   format,   getDateInstance,   getDateInstance,   getDateInstance,   getDateInstance,   getDateTimeInstance,   getDateTimeInstance,   getDateTimeInstance,   getDateTimeInstance,   getInstance,   getInstance,   getInstance,   getInstance,   getInstance,   getLocale,   getMaxLengthEstimate,   getPattern,   getTimeInstance,   getTimeInstance,   getTimeInstance,   getTimeInstance,   getTimeZone,   getTimeZoneDisplay,   getTimeZoneOverridesCalendar,   hashCode,   init,   parseObject,   parsePattern,   parseToken,   selectNumberRule,   toString
Methods from java.text.Format:
clone,   format,   format,   formatToCharacterIterator,   parseObject,   parseObject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.lang.time.FastDateFormat Detail:
 protected StringBuffer applyRules(Calendar calendar,
    StringBuffer buf) 

    Performs the formatting by applying the rules to the specified calendar.

 public boolean equals(Object obj) 

    Compares two objects for equality.

 public String format(long millis) 

    Formats a millisecond long value.

 public String format(Date date) 

    Formats a Date object.

 public String format(Calendar calendar) 

    Formats a Calendar object.

 public StringBuffer format(long millis,
    StringBuffer buf) 

    Formats a milliseond long value into the supplied StringBuffer.

 public StringBuffer format(Date date,
    StringBuffer buf) 

    Formats a Date object into the supplied StringBuffer.

 public StringBuffer format(Calendar calendar,
    StringBuffer buf) 

    Formats a Calendar object into the supplied StringBuffer.

 public StringBuffer format(Object obj,
    StringBuffer toAppendTo,
    FieldPosition pos) 

    Formats a Date, Calendar or Long (milliseconds) object.

 public static FastDateFormat getDateInstance(int style) 

    Gets a date formatter instance using the specified style in the default time zone and locale.

 public static FastDateFormat getDateInstance(int style,
    Locale locale) 

    Gets a date formatter instance using the specified style and locale in the default time zone.

 public static FastDateFormat getDateInstance(int style,
    TimeZone timeZone) 

    Gets a date formatter instance using the specified style and time zone in the default locale.

 public static synchronized FastDateFormat getDateInstance(int style,
    TimeZone timeZone,
    Locale locale) 

    Gets a date formatter instance using the specified style, time zone and locale.

 public static FastDateFormat getDateTimeInstance(int dateStyle,
    int timeStyle) 

    Gets a date/time formatter instance using the specified style in the default time zone and locale.

 public static FastDateFormat getDateTimeInstance(int dateStyle,
    int timeStyle,
    Locale 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 synchronized FastDateFormat getDateTimeInstance(int dateStyle,
    int timeStyle,
    TimeZone timeZone,
    Locale locale) 

    Gets a date/time formatter instance using the specified style, time zone and locale.

 public static FastDateFormat getInstance() 

    Gets a formatter instance using the default pattern in the default locale.

 public static FastDateFormat getInstance(String pattern) 

    Gets a formatter instance using the specified pattern in the default locale.

 public static FastDateFormat getInstance(String pattern,
    TimeZone timeZone) 

    Gets a formatter instance using the specified pattern and time zone.

 public static FastDateFormat getInstance(String pattern,
    Locale locale) 

    Gets a formatter instance using the specified pattern and locale.

 public static synchronized FastDateFormat getInstance(String pattern,
    TimeZone timeZone,
    Locale locale) 

    Gets a formatter instance using the specified pattern, time zone and locale.

 public Locale getLocale() 

    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.

 public String getPattern() 

    Gets the pattern used by this formatter.

 public static FastDateFormat getTimeInstance(int style) 

    Gets a time formatter instance using the specified style in the default time zone and locale.

 public static FastDateFormat getTimeInstance(int style,
    Locale locale) 

    Gets a time formatter instance using the specified style and locale in the default time zone.

 public static FastDateFormat getTimeInstance(int style,
    TimeZone timeZone) 

    Gets a time formatter instance using the specified style and time zone in the default locale.

 public static synchronized FastDateFormat getTimeInstance(int style,
    TimeZone timeZone,
    Locale locale) 

    Gets a time formatter instance using the specified style, time zone and locale.

 public TimeZone getTimeZone() 

    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() .

 static synchronized String getTimeZoneDisplay(TimeZone tz,
    boolean daylight,
    int style,
    Locale locale) 

    Gets the time zone display name, using a cache for performance.

 public boolean getTimeZoneOverridesCalendar() 

    Returns true if the time zone of the calendar overrides the time zone of the formatter.

 public int hashCode() 

    Returns a hashcode compatible with equals.

 protected  void init() 

    Initializes the instance for first use.

 public Object parseObject(String source,
    ParsePosition pos) 

    Parsing is not supported.

 protected List parsePattern() 

    Returns a list of Rules given a pattern.

 protected String parseToken(String pattern,
    int[] indexRef) 

    Performs the parsing of tokens.

 protected FastDateFormat.NumberRule selectNumberRule(int field,
    int padding) 

    Gets an appropriate rule for the padding required.

 public String toString() 

    Gets a debugging string version of this formatter.