Class DateCache

java.lang.Object
org.eclipse.jetty.util.DateCache

public class DateCache extends Object
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:
  • Field Details

  • 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

      public DateCache(String format)
      Make a DateCache that will use the given format.
      Parameters:
      format - the format to use
    • DateCache

      public DateCache(String format, Locale l)
    • DateCache

      public DateCache(String format, Locale l, String tz)
    • DateCache

      public DateCache(String format, Locale l, TimeZone tz)
    • DateCache

      public DateCache(String format, Locale l, TimeZone tz, boolean subSecondPrecision)
  • Method Details

    • getTimeZone

      public TimeZone getTimeZone()
    • format

      public String format(Date inDate)
      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

      public String format(long inDate)
      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

      protected String doFormat(long inDate, DateTimeFormatter formatter)
      Format a date according to supplied formatter.
      Parameters:
      inDate - the date in milliseconds since unix epoch.
      Returns:
      Formatted date.
    • formatTick

      protected DateCache.Tick formatTick(long inDate)
    • getFormatString

      public String getFormatString()