velosurf.util
Class FastHttpDateFormat

java.lang.Object
  extended by velosurf.util.FastHttpDateFormat

public class FastHttpDateFormat
extends java.lang.Object

Utility class to generate HTTP dates.

This source code is taken from Tomcat Apache

Author:
Remy Maucherat, Andrey Grebnev <andrey.grebnev@blandware.com>

Field Summary
private static java.lang.String currentDate
          Current formatted date.
private static long currentDateGenerated
          Instant on which the currentDate object was generated.
private static java.text.SimpleDateFormat format
          HTTP date format.
private static java.util.HashMap formatCache
          Formatter cache.
private static java.text.SimpleDateFormat[] formats
          The set of SimpleDateFormat formats to use in getDateHeader().
private static java.util.TimeZone gmtZone
          GMT timezone - all HTTP dates are on GMT
private static java.util.HashMap parseCache
          Parser cache.
 
Constructor Summary
FastHttpDateFormat()
           
 
Method Summary
static java.lang.String formatDate(long value, java.text.DateFormat threadLocalformat)
          Formats a specified date to HTTP format.
static java.lang.String getCurrentDate()
          Gets the current date in HTTP format.
private static java.lang.Long internalParseDate(java.lang.String value, java.text.DateFormat[] formats)
          Parses date with given formatters.
static long parseDate(java.lang.String value, java.text.DateFormat[] threadLocalformats)
          Tries to parse the given date as an HTTP date.
private static void updateCache(java.util.HashMap cache, java.lang.Object key, java.lang.Object value)
          Updates cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

format

private static final java.text.SimpleDateFormat format
HTTP date format.


formats

private static final java.text.SimpleDateFormat[] formats
The set of SimpleDateFormat formats to use in getDateHeader().


gmtZone

private static final java.util.TimeZone gmtZone
GMT timezone - all HTTP dates are on GMT


currentDateGenerated

private static long currentDateGenerated
Instant on which the currentDate object was generated.


currentDate

private static java.lang.String currentDate
Current formatted date.


formatCache

private static final java.util.HashMap formatCache
Formatter cache.


parseCache

private static final java.util.HashMap parseCache
Parser cache.

Constructor Detail

FastHttpDateFormat

public FastHttpDateFormat()
Method Detail

getCurrentDate

public static final java.lang.String getCurrentDate()
Gets the current date in HTTP format.

Returns:
Current date in HTTP format

formatDate

public static final java.lang.String formatDate(long value,
                                                java.text.DateFormat threadLocalformat)
Formats a specified date to HTTP format. If local format is not null, it's used instead.

Parameters:
value - Date value to format
threadLocalformat - The format to use (or null -- then HTTP format will be used)
Returns:
Formatted date

parseDate

public static final long parseDate(java.lang.String value,
                                   java.text.DateFormat[] threadLocalformats)
Tries to parse the given date as an HTTP date. If local format list is not null, it's used instead.

Parameters:
value - The string to parse
threadLocalformats - Array of formats to use for parsing. If null, HTTP formats are used.
Returns:
Parsed date (or -1 if error occured)

internalParseDate

private static final java.lang.Long internalParseDate(java.lang.String value,
                                                      java.text.DateFormat[] formats)
Parses date with given formatters.

Parameters:
value - The string to parse
formats - Array of formats to use
Returns:
Parsed date (or null if no formatter mached)

updateCache

private static final void updateCache(java.util.HashMap cache,
                                      java.lang.Object key,
                                      java.lang.Object value)
Updates cache.

Parameters:
cache - Cache to be updated
key - Key to be updated
value - New value


~ooOoo~