All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.servlet.http.HttpDate

java.lang.Object
   |
   +----sun.servlet.util.Ascii
           |
           +----sun.servlet.http.HttpDate

public class HttpDate
extends Ascii
This class can be used to efficiently parse and write an RFC 1123 formatted date in an HTTP message header.


Variable Index

 o BASE_DAY_OF_WEEK
 o DATELEN
Length of RFC 1123 format date string as written by getBytes().
 o days
Days of the week.
 o DAYS_PER_LEAP
 o DAYS_PER_YEAR
 o daysBeforeMonth
Number of days in a year before a given month.
 o daysBeforeMonthLeap
Number of days in a leap year before a given month.
 o daysInMonth
Number of days in the month.
 o daysInMonthLeap
Number of days in the month for a leap year.
 o hour
Hours, 0-based
 o mday
Day of the month, 1-based
 o min
Minutes, 0-based
 o mon
Month, 0-based
 o months
Months of the year.
 o sec
Seconds, 0-based
 o SECS_PER_DAY
 o SECS_PER_HOUR
 o SECS_PER_MIN
 o updater
Maintains updated current time.
 o wday
Weekday: Sun = 0, Sat = 6
 o year
Years since 1900

Constructor Index

 o HttpDate()
Creates a new HttpDate object.
 o HttpDate(long)
Creates a new HttpDate object using the specified time.

Method Index

 o daysBeforeMonth(int, int)
Returns number of days before the specified month of the specified year.
 o daysInMonth(int, int)
Returns number of days in the specified month of the specified year.
 o getBytes(byte[], int, int)
Writes an RFC 1123 formatted date to the specified subarray of bytes.
 o getCurrentTime()
Get the current time as number of milliseconds since the epoch.
 o getTime()
Returns the time as number of milliseconds since the epoch.
 o isLeapYear(int)
Returns true if the specified year is a leap year.
 o parse(byte[], int, int)
Parses an RFC 1123, RFC 1036, or ANSI C asctime() format date string from the specified byte array.
 o parse(String)
Parses an RFC 1123, RFC 1036, or ANSI C asctime() format date string from the specified string.
 o setTime()
Sets this HttpDate to the current time.
 o setTime(long)
Sets this HttpDate to the specified time.
 o toBytes(String)
Converts the specified string to an array of ascii bytes.
 o toString()
Returns a string representation of the date.
 o write(OutputStream)
Writes an RFC 1123 formatted date to the specified output stream.

Variables

 o sec
 protected int sec
Seconds, 0-based

 o min
 protected int min
Minutes, 0-based

 o hour
 protected int hour
Hours, 0-based

 o mday
 protected int mday
Day of the month, 1-based

 o mon
 protected int mon
Month, 0-based

 o year
 protected int year
Years since 1900

 o wday
 protected int wday
Weekday: Sun = 0, Sat = 6

 o days
 protected static final byte days[][]
Days of the week.

 o months
 protected static final byte months[][]
Months of the year.

 o daysInMonth
 protected static byte daysInMonth[]
Number of days in the month.

 o daysInMonthLeap
 protected static byte daysInMonthLeap[]
Number of days in the month for a leap year.

 o daysBeforeMonth
 protected static short daysBeforeMonth[]
Number of days in a year before a given month.

 o daysBeforeMonthLeap
 protected static short daysBeforeMonthLeap[]
Number of days in a leap year before a given month.

 o DATELEN
 public static final int DATELEN
Length of RFC 1123 format date string as written by getBytes().

 o updater
 protected static HttpDateUpdater updater
Maintains updated current time.

 o DAYS_PER_YEAR
 protected static int DAYS_PER_YEAR
 o DAYS_PER_LEAP
 protected static int DAYS_PER_LEAP
 o SECS_PER_MIN
 protected static int SECS_PER_MIN
 o SECS_PER_HOUR
 protected static int SECS_PER_HOUR
 o SECS_PER_DAY
 protected static int SECS_PER_DAY
 o BASE_DAY_OF_WEEK
 protected static int BASE_DAY_OF_WEEK

Constructors

 o HttpDate
 public HttpDate(long ms)
Creates a new HttpDate object using the specified time.

Parameters:
ms - the time in milliseconds since the epoch
 o HttpDate
 public HttpDate()
Creates a new HttpDate object.

Methods

 o parse
 public void parse(byte b[],
                   int off,
                   int len)
Parses an RFC 1123, RFC 1036, or ANSI C asctime() format date string from the specified byte array.

Parameters:
b - the bytes to parse
off - the start offset of the bytes
len - the length of the bytes
Throws: IllegalArgumentException
if the date format was invalid
 o parse
 public void parse(String s)
Parses an RFC 1123, RFC 1036, or ANSI C asctime() format date string from the specified string.

Parameters:
s - the string to parse
Throws: IllegalArgumentException
if the date format was invalid
 o write
 public void write(OutputStream out) throws IOException
Writes an RFC 1123 formatted date to the specified output stream.

Parameters:
out - the output stream
Throws: IOException
if an I/O error has occurred
 o toString
 public String toString()
Returns a string representation of the date.

Overrides:
toString in class Object
 o getBytes
 public int getBytes(byte b[],
                     int off,
                     int len)
Writes an RFC 1123 formatted date to the specified subarray of bytes.

Parameters:
b - the byte array
off - the offset of the bytes
len - the length of the bytes
Returns:
the number of bytes returned
Throws: IllegalArgumentException
if len < DATELEN
 o getTime
 public long getTime()
Returns the time as number of milliseconds since the epoch.

 o getCurrentTime
 public static long getCurrentTime()
Get the current time as number of milliseconds since the epoch. Similar to System.currentTimeMillis(), but with one second resolution.

 o isLeapYear
 protected static boolean isLeapYear(int year)
Returns true if the specified year is a leap year.

Parameters:
year - the year
 o daysInMonth
 protected static int daysInMonth(int mon,
                                  int year)
Returns number of days in the specified month of the specified year.

Parameters:
mon - the month, 0-based
year - the year since 1900
 o daysBeforeMonth
 protected static int daysBeforeMonth(int mon,
                                      int year)
Returns number of days before the specified month of the specified year.

Parameters:
mon - the month, 0-based
year - the year since 1900
 o setTime
 public void setTime(long ms)
Sets this HttpDate to the specified time.

Parameters:
ms - the time in milliseconds since the epoch
 o setTime
 public void setTime()
Sets this HttpDate to the current time.

 o toBytes
 protected static byte[] toBytes(String s)
Converts the specified string to an array of ascii bytes.

Parameters:
s - the string

All Packages  Class Hierarchy  This Package  Previous  Next  Index