Top Description Fields Constructors Methods
org.mortbay.util

public Class DateCache

extends Object
Class Inheritance
Imports
java.text.DateFormatSymbols, .SimpleDateFormat, java.util.Date, .Locale, .TimeZone

Date Format Cache. Computes String representations of Dates and caches the results so that subsequent requests within the same minute will be fast. Only format strings that contain either "ss" or "ss.SSS" are handled. The timezone of the date may be included as an ID with the "zzz" format string or as an offset with the "ZZZ" format string. If consecutive calls are frequently very different, then this may be a little slower than a normal DateFormat.
Authors
Kent Johnson , Greg Wilkins (gregw)

Field Summary

Modifier and TypeField and Description
private static long
private DateFormatSymbols
private String
private long
private int
private String
private long
private Locale
private SimpleDateFormat
private String
private String
private String
private String
private SimpleDateFormat
private String
public static String

Constructor Summary

AccessConstructor and Description
public
DateCache()

Constructor.

public
DateCache(String format)

Constructor.

public
DateCache(String format, Locale l)

public

Method Summary

Modifier and TypeMethod and Description
public synchronized String

Returns:

Formatted date
format
(Date inDate)

Format a date according to our stored formatter.

public synchronized String

Returns:

Formatted date
format
(long inDate)

Format a date according to our stored formatter.

public void
format(long
Date the format
inDate
,
StringBuilder
StringBuilder
buffer
)

Format to string buffer.

public SimpleDateFormat
getFormat()

Get the format.

public String
public TimeZone
public int
public String
now()

private void
public void
setTimeZone(TimeZone
TimeZone
tz
)

Set the timezone.

public void
setTimeZoneID(String
TimeZoneId the ID of the zone as used by TimeZone.getTimeZone(id)
timeZoneId
)

Set the timezone.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__hitWindowback to summary
private static long __hitWindow
_dfsback to summary
private DateFormatSymbols _dfs
_formatStringback to summary
private String _formatString
_lastMinutesback to summary
private long _lastMinutes
_lastMsback to summary
private int _lastMs
_lastResultback to summary
private String _lastResult
_lastSecondsback to summary
private long _lastSeconds
_localeback to summary
private Locale _locale
_minFormatback to summary
private SimpleDateFormat _minFormat
_minFormatStringback to summary
private String _minFormatString
_secFormatStringback to summary
private String _secFormatString
_secFormatString0back to summary
private String _secFormatString0
_secFormatString1back to summary
private String _secFormatString1
_tzFormatback to summary
private SimpleDateFormat _tzFormat
_tzFormatStringback to summary
private String _tzFormatString
DEFAULT_FORMATback to summary
public static String DEFAULT_FORMAT

Constructor Detail

DateCacheback to summary
public DateCache()

Constructor. Make a DateCache that will use a default format. The default format generates the same results as Date.toString().

DateCacheback to summary
public DateCache(String format)

Constructor. Make a DateCache that will use the given format

DateCacheback to summary
public DateCache(String format, Locale l)
DateCacheback to summary
public DateCache(String format, DateFormatSymbols s)

Method Detail

formatback to summary
public synchronized String format(Date inDate)

Format a date according to our stored formatter.

Returns:String

Formatted date

formatback to summary
public synchronized String format(long inDate)

Format a date according to our stored formatter.

Returns:String

Formatted date

formatback to summary
public void format(long inDate, StringBuilder buffer)

Format to string buffer.

Parameters
inDate:long

Date the format

buffer:StringBuilder

StringBuilder

getFormatback to summary
public SimpleDateFormat getFormat()

Get the format.

getFormatStringback to summary
public String getFormatString()
getTimeZoneback to summary
public TimeZone getTimeZone()
lastMsback to summary
public int lastMs()
nowback to summary
public String now()
setMinFormatStringback to summary
private void setMinFormatString()
setTimeZoneback to summary
public void setTimeZone(TimeZone tz)

Set the timezone.

Parameters
tz:TimeZone

TimeZone

setTimeZoneIDback to summary
public void setTimeZoneID(String timeZoneId)

Set the timezone.

Parameters
timeZoneId:String

TimeZoneId the ID of the zone as used by TimeZone.getTimeZone(id)

setTzFormatStringback to summary
private void setTzFormatString(final TimeZone tz)