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.
-
BASE_DAY_OF_WEEK
-
-
DATELEN
- Length of RFC 1123 format date string as written by getBytes().
-
days
- Days of the week.
-
DAYS_PER_LEAP
-
-
DAYS_PER_YEAR
-
-
daysBeforeMonth
- Number of days in a year before a given month.
-
daysBeforeMonthLeap
- Number of days in a leap year before a given month.
-
daysInMonth
- Number of days in the month.
-
daysInMonthLeap
- Number of days in the month for a leap year.
-
hour
- Hours, 0-based
-
mday
- Day of the month, 1-based
-
min
- Minutes, 0-based
-
mon
- Month, 0-based
-
months
- Months of the year.
-
sec
- Seconds, 0-based
-
SECS_PER_DAY
-
-
SECS_PER_HOUR
-
-
SECS_PER_MIN
-
-
updater
- Maintains updated current time.
-
wday
- Weekday: Sun = 0, Sat = 6
-
year
- Years since 1900
-
HttpDate()
- Creates a new HttpDate object.
-
HttpDate(long)
- Creates a new HttpDate object using the specified time.
-
daysBeforeMonth(int, int)
- Returns number of days before the specified month of the specified
year.
-
daysInMonth(int, int)
- Returns number of days in the specified month of the specified
year.
-
getBytes(byte[], int, int)
- Writes an RFC 1123 formatted date to the specified subarray of bytes.
-
getCurrentTime()
- Get the current time as number of milliseconds since the epoch.
-
getTime()
- Returns the time as number of milliseconds since the epoch.
-
isLeapYear(int)
- Returns true if the specified year is a leap year.
-
parse(byte[], int, int)
- Parses an RFC 1123, RFC 1036, or ANSI C asctime() format date string
from the specified byte array.
-
parse(String)
- Parses an RFC 1123, RFC 1036, or ANSI C asctime() format date string
from the specified string.
-
setTime()
- Sets this HttpDate to the current time.
-
setTime(long)
- Sets this HttpDate to the specified time.
-
toBytes(String)
- Converts the specified string to an array of ascii bytes.
-
toString()
- Returns a string representation of the date.
-
write(OutputStream)
- Writes an RFC 1123 formatted date to the specified output stream.
sec
protected int sec
- Seconds, 0-based
min
protected int min
- Minutes, 0-based
hour
protected int hour
- Hours, 0-based
mday
protected int mday
- Day of the month, 1-based
mon
protected int mon
- Month, 0-based
year
protected int year
- Years since 1900
wday
protected int wday
- Weekday: Sun = 0, Sat = 6
days
protected static final byte days[][]
- Days of the week.
months
protected static final byte months[][]
- Months of the year.
daysInMonth
protected static byte daysInMonth[]
- Number of days in the month.
daysInMonthLeap
protected static byte daysInMonthLeap[]
- Number of days in the month for a leap year.
daysBeforeMonth
protected static short daysBeforeMonth[]
- Number of days in a year before a given month.
daysBeforeMonthLeap
protected static short daysBeforeMonthLeap[]
- Number of days in a leap year before a given month.
DATELEN
public static final int DATELEN
- Length of RFC 1123 format date string as written by getBytes().
updater
protected static HttpDateUpdater updater
- Maintains updated current time.
DAYS_PER_YEAR
protected static int DAYS_PER_YEAR
DAYS_PER_LEAP
protected static int DAYS_PER_LEAP
SECS_PER_MIN
protected static int SECS_PER_MIN
SECS_PER_HOUR
protected static int SECS_PER_HOUR
SECS_PER_DAY
protected static int SECS_PER_DAY
BASE_DAY_OF_WEEK
protected static int BASE_DAY_OF_WEEK
HttpDate
public HttpDate(long ms)
- Creates a new HttpDate object using the specified time.
- Parameters:
- ms - the time in milliseconds since the epoch
HttpDate
public HttpDate()
- Creates a new HttpDate object.
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
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
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
toString
public String toString()
- Returns a string representation of the date.
- Overrides:
- toString in class Object
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
getTime
public long getTime()
- Returns the time as number of milliseconds since the epoch.
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.
isLeapYear
protected static boolean isLeapYear(int year)
- Returns true if the specified year is a leap year.
- Parameters:
- year - the year
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
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
setTime
public void setTime(long ms)
- Sets this HttpDate to the specified time.
- Parameters:
- ms - the time in milliseconds since the epoch
setTime
public void setTime()
- Sets this HttpDate to the current time.
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