Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http.util

public final Class FastHttpDateFormat

extends Object
Class Inheritance
Annotations
@Deprecated
Static Imports
org.glassfish.grizzly.http.util.HttpCodecUtils.toCheckedByteArray

Deprecated

Utility class to generate HTTP dates.
Authors
Gustav Trede, Remy Maucherat

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
private static String
cachedStringDate

Current formatted date.

private static final StringBuffer
private static byte[]
currentDateBytes

Current formatted date as byte[].

private static volatile byte[]
private static final ThreadLocal<FastHttpDateFormat.SimpleDateFormatter>
FORMAT

HTTP date format.

private static final ConcurrentMap<Long, String>
formatCache

Formatter cache.

private static final ThreadLocal<T>
FORMATS

ThreadLocal for the set of SimpleDateFormat formats to use in getDateHeader().

private static final FastHttpDateFormat.SimpleDateFormatter
private static final TimeZone
private static final AtomicBoolean
private static volatile long
nextGeneration

Instant on which the currentDate object was generated.

private static final ConcurrentMap<String, Long>
parseCache

Parser cache.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String
formatDate(long
in milli-seconds
value
,
DateFormat
the DateFormat used if cache value was not found
threadLocalFormat
)

Get the HTTP format of the specified date.

public static String
getCurrentDate()

Get the current date in HTTP format.

public static byte[]
getCurrentDateBytes()

Get the current date in HTTP format.

private static long
internalParseDate(String value, DateFormat[] formats)

Parse date with given formatters.

public static long
parseDate(final String value, DateFormat[] threadLocalformats)

Try to parse the given date as a HTTP date.

private static void
updateFormatCache(Long key, String value)

Update cache.

private static void
updateParseCache(String key, Long value)

Update cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASCII_CHARSET_NAMEback to summary
private static final String ASCII_CHARSET_NAME
CACHE_SIZEback to summary
private static final int CACHE_SIZE
cachedStringDateback to summary
private static String cachedStringDate

Current formatted date.

currentDateBufferback to summary
private static final StringBuffer currentDateBuffer
currentDateBytesback to summary
private static byte[] currentDateBytes

Current formatted date as byte[].

dateBytesForCachedStringDateback to summary
private static volatile byte[] dateBytesForCachedStringDate
FORMATback to summary
private static final ThreadLocal<FastHttpDateFormat.SimpleDateFormatter> FORMAT

HTTP date format.

formatCacheback to summary
private static final ConcurrentMap<Long, String> formatCache

Formatter cache.

FORMATSback to summary
private static final ThreadLocal<T> FORMATS

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

FORMATTERback to summary
private static final FastHttpDateFormat.SimpleDateFormatter FORMATTER
GMT_TIME_ZONEback to summary
private static final TimeZone GMT_TIME_ZONE
isGeneratingNowback to summary
private static final AtomicBoolean isGeneratingNow
nextGenerationback to summary
private static volatile long nextGeneration

Instant on which the currentDate object was generated.

parseCacheback to summary
private static final ConcurrentMap<String, Long> parseCache

Parser cache.

Constructor Detail

FastHttpDateFormatback to summary
public FastHttpDateFormat()

Method Detail

formatDateback to summary
public static String formatDate(long value, DateFormat threadLocalFormat)

Get the HTTP format of the specified date.
http spec only require second precision http://tools.ietf.org/html/rfc2616#page-20
therefore we don't use the millisecond precision , but second . truncation is done in the same way for second precision in SimpleDateFormat:
(999 millisec. = 0 sec.)

Parameters
value:long

in milli-seconds

threadLocalFormat:DateFormat

the DateFormat used if cache value was not found

getCurrentDateback to summary
public static String getCurrentDate()

Get the current date in HTTP format.

getCurrentDateBytesback to summary
public static byte[] getCurrentDateBytes()

Get the current date in HTTP format.

internalParseDateback to summary
private static long internalParseDate(String value, DateFormat[] formats)

Parse date with given formatters.

parseDateback to summary
public static long parseDate(final String value, DateFormat[] threadLocalformats)

Try to parse the given date as a HTTP date.

updateFormatCacheback to summary
private static void updateFormatCache(Long key, String value)

Update cache.

updateParseCacheback to summary
private static void updateParseCache(String key, Long value)

Update cache.

org.glassfish.grizzly.http.util back to summary

private final Class FastHttpDateFormat.SimpleDateFormatter

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.http.util.FastHttpDateFormat.SimpleDateFormatter

Field Summary

Modifier and TypeField and Description
private final Date
private final SimpleDateFormat
f

private final FieldPosition

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
format(final long timeMillis)

public StringBuffer
formatTo(final long timeMillis, final StringBuffer buffer)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dateback to summary
private final Date date
fback to summary
private final SimpleDateFormat f
posback to summary
private final FieldPosition pos

Constructor Detail

SimpleDateFormatterback to summary
public SimpleDateFormatter()

Method Detail

formatback to summary
public String format(final long timeMillis)
formatToback to summary
public StringBuffer formatTo(final long timeMillis, final StringBuffer buffer)