kom.tools.web
Class ParseDate

java.lang.Object
  |
  +--kom.tools.web.ParseDate

public class ParseDate
extends java.lang.Object

Parser for date format in HTTP rfc1123, rfc850 or asctime


Field Summary
static java.lang.String ASCTIME_FORMAT
           
(package private) static java.util.Hashtable longNames
           
static java.lang.String RFC1123_FORMAT
           
static java.lang.String RFC850_FORMAT
           
(package private) static java.util.Hashtable shortNames
           
 
Constructor Summary
ParseDate()
           
 
Method Summary
(package private) static void ()
          Initialization of day-of-week name tables
static java.lang.String asctime(java.util.Date d)
          Formats a Date in ASCTIME format
static java.lang.String format(java.util.Date d, java.lang.String format)
          Formats a Date
(package private) static void insertName(java.lang.String shortName, java.lang.String longName)
          Inserts a short and a long day-of-week name in the respective tables, with the corresponding WeekDay object as value
static java.lang.String long2short(java.lang.String day)
          Finds the short day name corresponding to the long name
static java.util.Date parse(java.lang.String date)
          Parses a date string, trying RFC1123, RFC850 and ASCTIME formats in turn
static java.util.Date parse(java.lang.String date, java.lang.String format)
          Parses a date String with a specified format
static java.util.Date parseASCTIME(java.lang.String date)
          Parses ASCTIME string Example: Mon Jan 2 22:11:06 1982
static java.util.Date parseRFC1123(java.lang.String date)
          Parses date string according to RFC1123 Example: Mon, 02 Jun 1982 22:11:06 GMT
static java.util.Date parseRFC850(java.lang.String date)
          Parses date string according to RFC850 Example: Monday, 02-Jan-82 22:11:06 GMT
static java.lang.String rfc1123(java.util.Date d)
          Formats a Date according to RFC1123
static java.lang.String rfc850(java.util.Date d)
          Formats a Date according to RFC850
static java.lang.String short2long(java.lang.String day)
          Finds the long day name corresponding to the short name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

longNames

static java.util.Hashtable longNames

shortNames

static java.util.Hashtable shortNames

RFC1123_FORMAT

public static final java.lang.String RFC1123_FORMAT

RFC850_FORMAT

public static final java.lang.String RFC850_FORMAT

ASCTIME_FORMAT

public static final java.lang.String ASCTIME_FORMAT
Constructor Detail

ParseDate

public ParseDate()
Method Detail

static void ()
Initialization of day-of-week name tables

insertName

static void insertName(java.lang.String shortName,
                       java.lang.String longName)
Inserts a short and a long day-of-week name in the respective tables, with the corresponding WeekDay object as value
Parameters:
shortName - Short form of day name
longName - Long form of day name

long2short

public static java.lang.String long2short(java.lang.String day)
Finds the short day name corresponding to the long name
Parameters:
day - Long day name
Returns:
Short form of name

short2long

public static java.lang.String short2long(java.lang.String day)
Finds the long day name corresponding to the short name
Parameters:
day - Short day name
Returns:
Long form of name

parse

public static java.util.Date parse(java.lang.String date,
                                   java.lang.String format)
Parses a date String with a specified format
Parameters:
date - The date/time string
format - The format
Returns:
Date object corresponding to the string, or null

parseRFC1123

public static java.util.Date parseRFC1123(java.lang.String date)
Parses date string according to RFC1123 Example: Mon, 02 Jun 1982 22:11:06 GMT
Parameters:
date - The date/time string
Returns:
Date object corresponding to the string, or null

parseRFC850

public static java.util.Date parseRFC850(java.lang.String date)
Parses date string according to RFC850 Example: Monday, 02-Jan-82 22:11:06 GMT
Parameters:
date - The date/time string
Returns:
Date object corresponding to the string, or null

parseASCTIME

public static java.util.Date parseASCTIME(java.lang.String date)
Parses ASCTIME string Example: Mon Jan 2 22:11:06 1982
Parameters:
date - The date/time string
Returns:
Date object corresponding to the string, or null

parse

public static java.util.Date parse(java.lang.String date)
Parses a date string, trying RFC1123, RFC850 and ASCTIME formats in turn
Parameters:
date - The date/time string
Returns:
Date object corresponding to the string, or null

format

public static java.lang.String format(java.util.Date d,
                                      java.lang.String format)
Formats a Date
Parameters:
d - The date object
format - The format string for the output

rfc850

public static java.lang.String rfc850(java.util.Date d)
Formats a Date according to RFC850
Parameters:
d - The date object
Returns:
Formatted date string

rfc1123

public static java.lang.String rfc1123(java.util.Date d)
Formats a Date according to RFC1123
Parameters:
d - The date object
Returns:
Formatted date string

asctime

public static java.lang.String asctime(java.util.Date d)
Formats a Date in ASCTIME format
Parameters:
d - The date object
Returns:
Formatted date string