Package org.eclipse.jetty.util
Class DateCache
java.lang.Object
org.eclipse.jetty.util.DateCache
Computes String representations of Dates then caches the results so
that subsequent requests within the same second will be fast.
If consecutive calls are frequently very different, then this may be a little slower than a normal DateFormat.
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMake a DateCache that will use a default format.Make a DateCache that will use the given format. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
doFormat
(long inDate, DateTimeFormatter formatter) Format a date according to supplied formatter.format
(long inDate) Format a date according to our stored formatter.Format a date according to our stored formatter.formatNow
(long now) Deprecated.protected DateCache.Tick
formatTick
(long inDate) now()
Deprecated.tick()
Deprecated.
-
Field Details
-
DEFAULT_FORMAT
- See Also:
-
-
Constructor Details
-
DateCache
public DateCache()Make a DateCache that will use a default format. The default format generates the same results as Date.toString(). -
DateCache
Make a DateCache that will use the given format.- Parameters:
format
- the format to use
-
DateCache
-
DateCache
-
DateCache
-
DateCache
-
-
Method Details
-
getTimeZone
-
format
Format a date according to our stored formatter. If it happens to be in the same second as the last formatNow call, then the format is reused.- Parameters:
inDate
- the Date.- Returns:
- Formatted date.
-
format
Format a date according to our stored formatter. If it happens to be in the same second as the last formatNow call, then the format is reused.- Parameters:
inDate
- the date in milliseconds since unix epoch.- Returns:
- Formatted date.
-
doFormat
Format a date according to supplied formatter.- Parameters:
inDate
- the date in milliseconds since unix epoch.- Returns:
- Formatted date.
-
formatNow
Deprecated.useformat(long)
Format a date according to our stored formatter. The passed time is expected to be close to the current time, so it is compared to the last value passed and if it is within the same second, the format is reused. Otherwise, a new cached format is created.- Parameters:
now
- the milliseconds since unix epoch- Returns:
- Formatted date
-
now
Deprecated. -
tick
Deprecated. -
formatTick
-
getFormatString
-
format(long)