com.sun.grizzly.util.http
Class FastHttpDateFormat

java.lang.Object
  extended by com.sun.grizzly.util.http.FastHttpDateFormat

public final class FastHttpDateFormat
extends Object

Utility class to generate HTTP dates.

Author:
Gustav Trede, Remy Maucherat

Field Summary
protected static int CACHE_SIZE
           
protected static String currentDate
          Current formatted date.
protected static ThreadLocal<SimpleDateFormat> FORMAT
          HTTP date format.
protected static ConcurrentHashMap<Long,String> formatCache
          Formatter cache.
protected static ThreadLocal FORMATS
          ThreadLocal for the set of SimpleDateFormat formats to use in getDateHeader().
protected static TimeZone GMT_TIME_ZONE
           
protected static TimeZone gmtZone
           
protected static long nextGeneration
          Instant on which the currentDate object was generated.
protected static ConcurrentHashMap<String,Long> parseCache
          Parser cache.
 
Constructor Summary
FastHttpDateFormat()
           
 
Method Summary
static String formatDate(long value, DateFormat threadLocalformat)
          Get the HTTP format of the specified date.
http spec only requre second precision http://tools.ietf.org/html/rfc2616#page-20
therefore we dont use the millisecond precision , but second .
static String getCurrentDate()
          Get the current date in HTTP format.
static long parseDate(String value, DateFormat[] threadLocalformats)
          Try to parse the given date as a HTTP date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_SIZE

protected static final int CACHE_SIZE
See Also:
Constant Field Values

GMT_TIME_ZONE

protected static final TimeZone GMT_TIME_ZONE

FORMAT

protected static final ThreadLocal<SimpleDateFormat> FORMAT
HTTP date format.


gmtZone

protected static final TimeZone gmtZone

FORMATS

protected static final ThreadLocal FORMATS
ThreadLocal for the set of SimpleDateFormat formats to use in getDateHeader(). GMT timezone - all HTTP dates are on GMT


nextGeneration

protected static volatile long nextGeneration
Instant on which the currentDate object was generated.


currentDate

protected static volatile String currentDate
Current formatted date.


formatCache

protected static final ConcurrentHashMap<Long,String> formatCache
Formatter cache.


parseCache

protected static final ConcurrentHashMap<String,Long> parseCache
Parser cache.

Constructor Detail

FastHttpDateFormat

public FastHttpDateFormat()
Method Detail

getCurrentDate

public static final String getCurrentDate()
Get the current date in HTTP format.


formatDate

public static final String formatDate(long value,
                                      DateFormat threadLocalformat)
Get the HTTP format of the specified date.
http spec only requre second precision http://tools.ietf.org/html/rfc2616#page-20
therefore we dont use the millisecond precision , but second . truncation is done in the same way for second precision in SimpleDateFormat:
(999 millisec. = 0 sec.)

Parameters:
timestamp - in millisec
the - formater used if cache value was not found

parseDate

public static final long parseDate(String value,
                                   DateFormat[] threadLocalformats)
Try to parse the given date as a HTTP date.



Copyright © 2012 Oracle Corporation. All Rights Reserved.