org.mortbay.util
Class DateCache
java.lang.Object
org.mortbay.util.DateCache
public class DateCache
extends java.lang.Object
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.
$Id: DateCache.java,v 1.15 2004/05/09 20:32:49 gregwilkins Exp $- Kent Johnson
- Greg Wilkins (gregw)
String | format(Date inDate) - Format a date according to our stored formatter.
|
String | format(long inDate) - Format a date according to our stored formatter.
|
void | format(long inDate, StringBuffer buffer) - Format to string buffer.
|
SimpleDateFormat | getFormat() - Get the format.
|
String | getFormatString()
|
TimeZone | getTimeZone()
|
void | setTimeZone(TimeZone tz) - Set the timezone.
|
void | setTimeZoneID(String timeZoneId) - Set the timezone.
|
DateCache
public DateCache()
Constructor.
Make a DateCache that will use a default format. The default format
generates the same results as Date.toString().
DateCache
public DateCache(String format)
Constructor.
Make a DateCache that will use the given format
DateCache
public DateCache(String format,
DateFormatSymbols s)
DateCache
public DateCache(String format,
Locale l)
format
public String format(Date inDate)
Format a date according to our stored formatter.
format
public String format(long inDate)
Format a date according to our stored formatter.
format
public void format(long inDate,
StringBuffer buffer)
Format to string buffer.
inDate
- Date the formatbuffer
- StringBuffer
getFormat
public SimpleDateFormat getFormat()
Get the format.
getFormatString
public String getFormatString()
getTimeZone
public TimeZone getTimeZone()
setTimeZone
public void setTimeZone(TimeZone tz)
Set the timezone.
setTimeZoneID
public void setTimeZoneID(String timeZoneId)
Set the timezone.
timeZoneId
- TimeZoneId the ID of the zone as used by
TimeZone.getTimeZone(id)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.