Spring Security Framework

org.springframework.security.ui.savedrequest
Class FastHttpDateFormat

java.lang.Object
  extended by org.springframework.security.ui.savedrequest.FastHttpDateFormat

public class FastHttpDateFormat
extends Object

Utility class to generate HTTP dates.

This class is based on code in Apache Tomcat.

Version:
$Id$
Author:
Remy Maucherat, Andrey Grebnev

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

Field Detail

format

protected static final SimpleDateFormat format
HTTP date format.


formats

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


gmtZone

protected static final TimeZone gmtZone
GMT timezone - all HTTP dates are on GMT


currentDateGenerated

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


currentDate

protected static String currentDate
Current formatted date.


formatCache

protected static final HashMap formatCache
Formatter cache.


parseCache

protected static final HashMap parseCache
Parser cache.

Constructor Detail

FastHttpDateFormat

public FastHttpDateFormat()
Method Detail

formatDate

public static final String formatDate(long value,
                                      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

getCurrentDate

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

Returns:
Current date in HTTP format

parseDate

public static final long parseDate(String value,
                                   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)

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.