|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.text.Format java.text.DateFormat org.apache.log4j.pattern.CachedDateFormat
public final class CachedDateFormat
CachedDateFormat optimizes the performance of a wrapped DateFormat. The implementation is not thread-safe. If the millisecond pattern is not recognized, the class will only use the cache if the same value is requested.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.text.DateFormat |
---|
DateFormat.Field |
Field Summary | |
---|---|
static int |
NO_MILLISECONDS
Constant used to represent that there was no change observed when changing the millisecond count. |
static int |
UNRECOGNIZED_MILLISECONDS
Constant used to represent that there was an observed change, but was an expected change. |
Fields inherited from class java.text.DateFormat |
---|
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD |
Constructor Summary | |
---|---|
CachedDateFormat(DateFormat dateFormat,
int expiration)
Creates a new CachedDateFormat object. |
Method Summary | |
---|---|
static int |
findMillisecondStart(long time,
String formatted,
DateFormat formatter)
Finds start of millisecond field in formatted time. |
StringBuffer |
format(Date date,
StringBuffer sbuf,
FieldPosition fieldPosition)
Formats a Date into a date/time string. |
StringBuffer |
format(long now,
StringBuffer buf)
Formats a millisecond count into a date/time string. |
static int |
getMaximumCacheValidity(String pattern)
Gets maximum cache validity for the specified SimpleDateTime conversion pattern. |
NumberFormat |
getNumberFormat()
Gets number formatter. |
Date |
parse(String s,
ParsePosition pos)
This method is delegated to the formatter which most likely returns null. |
void |
setTimeZone(TimeZone timeZone)
Set timezone. |
Methods inherited from class java.text.DateFormat |
---|
clone, equals, format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, hashCode, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat |
Methods inherited from class java.text.Format |
---|
format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_MILLISECONDS
public static final int UNRECOGNIZED_MILLISECONDS
Constructor Detail |
---|
public CachedDateFormat(DateFormat dateFormat, int expiration)
dateFormat
- Date format, may not be null.expiration
- maximum cached range in milliseconds.
If the dateFormat is known to be incompatible with the
caching algorithm, use a value of 0 to totally disable
caching or 1 to only use cache for duplicate requests.Method Detail |
---|
public static int findMillisecondStart(long time, String formatted, DateFormat formatter)
time
- long time, must be integral number of secondsformatted
- String corresponding formatted stringformatter
- DateFormat date format
public StringBuffer format(Date date, StringBuffer sbuf, FieldPosition fieldPosition)
format
in class DateFormat
date
- the date to format.sbuf
- the string buffer to write to.fieldPosition
- remains untouched.
public StringBuffer format(long now, StringBuffer buf)
now
- Number of milliseconds after midnight 1 Jan 1970 GMT.buf
- the string buffer to write to.
public void setTimeZone(TimeZone timeZone)
setTimeZone
in class DateFormat
timeZone
- TimeZone new timezonepublic Date parse(String s, ParsePosition pos)
parse
in class DateFormat
s
- string representation of date.pos
- field position, unused.
public NumberFormat getNumberFormat()
getNumberFormat
in class DateFormat
public static int getMaximumCacheValidity(String pattern)
pattern
- conversion pattern, may not be null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |