|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--calypso.util.NetworkDate
Parses a date out of a string of bytes. Call it like this:
Note that it operates on bytes, not chars, since network dates are always ASCII.
Why would you want to use this instead of java.text.DateFormat.parse()? Because this algorithm has been tested in the field against real-world message headers for several years (the C code hadn't changed substantively since Netscape 2.0.) (There had been DST-related problems, but the tokenizer/parser was always sound.)
Date
,
Calendar
,
DateFormat
Method Summary | |
static java.util.Date |
parseDate(ByteBuf string)
The same, but assumes GMT is the default timezone. |
static java.util.Date |
parseDate(ByteBuf string,
boolean default_to_gmt)
Like parseLong(), but returns a new Date object instead. |
static long |
parseLong(byte[] string,
int start,
int end,
boolean default_to_gmt)
The same, but takes a byte array and a region within it, instead of a ByteBuf. |
static long |
parseLong(ByteBuf string)
The same, but assumes GMT is the default timezone. |
static long |
parseLong(ByteBuf buf,
boolean default_to_gmt)
This parses a time/date string into a Time object. |
static long |
UTC(int year,
int month,
int date,
int hour,
int min,
int sec)
Composes the given date into a number suitable for passing to new Date(n). |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static long parseLong(ByteBuf buf, boolean default_to_gmt)
Many formats are handled, including:
But note that 6/5/95 is ambiguous, since it's not obvious which is the day and which is the month. (6/13/95 is not ambiguous, however.)
buf
- The bytes to parse. This assumes the input to be
a sequence of 8-bit ASCII characters. High-bit
characters are handled; 16-bit Unicode characters
are not.default_to_gmt
- If the input string doesn't contain a description
of the timezone, then this argument determines whether the string is
interpreted relative to the local time zone (false) or to GMT (true).
The correct value to pass in for this argument depends on what standard
specified the time string which you are parsing; for RFC822 dates, this
argument should be true.public static long parseLong(byte[] string, int start, int end, boolean default_to_gmt)
public static long parseLong(ByteBuf string)
public static java.util.Date parseDate(ByteBuf string, boolean default_to_gmt)
public static java.util.Date parseDate(ByteBuf string)
public static long UTC(int year, int month, int date, int hour, int min, int sec)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |