mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 12:37:37 +00:00
356 lines
14 KiB
HTML
356 lines
14 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
<!--NewPage-->
|
|
<HTML>
|
|
<HEAD>
|
|
<!-- Generated by javadoc on Sun Aug 01 23:07:08 MDT 1999 -->
|
|
<TITLE>
|
|
: Class NetworkDate
|
|
</TITLE>
|
|
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
|
|
</HEAD>
|
|
<BODY BGCOLOR="white">
|
|
|
|
<!-- ========== START OF NAVBAR ========== -->
|
|
<A NAME="navbar_top"><!-- --></A>
|
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
|
|
<TR>
|
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1">
|
|
<A NAME="navbar_top_firstrow"><!-- --></A>
|
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
|
|
<TR ALIGN="center" VALIGN="top">
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> <FONT ID="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
|
</TR>
|
|
</TABLE>
|
|
</TD>
|
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
|
</EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../calypso/util/MemoryMonitor.html"><B>PREV CLASS</B></A>
|
|
<A HREF="../../calypso/util/NullEnumeration.html"><B>NEXT CLASS</B></A></FONT></TD>
|
|
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>
|
|
<A HREF="NetworkDate.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
|
|
SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
<!-- =========== END OF NAVBAR =========== -->
|
|
|
|
<HR>
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<H2>
|
|
<FONT SIZE="-1">
|
|
calypso.util</FONT>
|
|
<BR>
|
|
Class NetworkDate</H2>
|
|
<PRE>
|
|
java.lang.Object
|
|
|
|
|
+--<B>calypso.util.NetworkDate</B>
|
|
</PRE>
|
|
<HR>
|
|
<DL>
|
|
<DT>public class <B>NetworkDate</B><DT>extends java.lang.Object</DL>
|
|
|
|
<P>
|
|
Parses a date out of a string of bytes. Call it like this:
|
|
|
|
<P><UL>
|
|
<TT>ByteBuf bytes = </TT>...<TT> ;</TT><BR>
|
|
<TT>Date date = NetworkDate.parseDate(bytes);</TT>
|
|
</UL>
|
|
|
|
<P> Note that it operates on bytes, not chars, since network
|
|
dates are always ASCII.
|
|
|
|
<P> Why would you want to use this instead of
|
|
<TT>java.text.DateFormat.parse()</TT>? 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.)
|
|
<P>
|
|
<DL>
|
|
<DT><B>See Also: </B><DD><CODE>Date</CODE>,
|
|
<CODE>Calendar</CODE>,
|
|
<CODE>DateFormat</CODE></DL>
|
|
<HR>
|
|
|
|
<P>
|
|
<!-- ======== INNER CLASS SUMMARY ======== -->
|
|
|
|
|
|
<!-- =========== FIELD SUMMARY =========== -->
|
|
|
|
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
|
|
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
|
|
<A NAME="method_summary"><!-- --></A>
|
|
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
|
|
<TR BGCOLOR="#CCCCFF" ID="TableHeadingColor">
|
|
<TD COLSPAN=2><FONT SIZE="+2">
|
|
<B>Method Summary</B></FONT></TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE>static java.util.Date</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../calypso/util/NetworkDate.html#parseDate(calypso.util.ByteBuf)">parseDate</A></B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> string)</CODE>
|
|
|
|
<BR>
|
|
The same, but assumes GMT is the default timezone.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE>static java.util.Date</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../calypso/util/NetworkDate.html#parseDate(calypso.util.ByteBuf, boolean)">parseDate</A></B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> string,
|
|
boolean default_to_gmt)</CODE>
|
|
|
|
<BR>
|
|
Like parseLong(), but returns a new Date object instead.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE>static long</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../calypso/util/NetworkDate.html#parseLong(byte[], int, int, boolean)">parseLong</A></B>(byte[] string,
|
|
int start,
|
|
int end,
|
|
boolean default_to_gmt)</CODE>
|
|
|
|
<BR>
|
|
The same, but takes a byte array and a region within it, instead
|
|
of a ByteBuf.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE>static long</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../calypso/util/NetworkDate.html#parseLong(calypso.util.ByteBuf)">parseLong</A></B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> string)</CODE>
|
|
|
|
<BR>
|
|
The same, but assumes GMT is the default timezone.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE>static long</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../calypso/util/NetworkDate.html#parseLong(calypso.util.ByteBuf, boolean)">parseLong</A></B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> buf,
|
|
boolean default_to_gmt)</CODE>
|
|
|
|
<BR>
|
|
This parses a time/date string into a Time object.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE>static long</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../calypso/util/NetworkDate.html#UTC(int, int, int, int, int, int)">UTC</A></B>(int year,
|
|
int month,
|
|
int date,
|
|
int hour,
|
|
int min,
|
|
int sec)</CODE>
|
|
|
|
<BR>
|
|
Composes the given date into a number suitable for passing to
|
|
<TT>new Date(n)</TT>.</TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
|
|
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
|
|
<TR BGCOLOR="#EEEEFF" ID="TableSubHeadingColor">
|
|
<TD><B>Methods inherited from class java.lang.Object</B></TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" ID="TableRowColor">
|
|
<TD><CODE>clone,
|
|
equals,
|
|
finalize,
|
|
getClass,
|
|
hashCode,
|
|
notify,
|
|
notifyAll,
|
|
toString,
|
|
wait,
|
|
wait,
|
|
wait</CODE></TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<!-- ============ FIELD DETAIL =========== -->
|
|
|
|
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
|
|
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
|
|
<A NAME="method_detail"><!-- --></A>
|
|
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
|
|
<TR BGCOLOR="#CCCCFF" ID="TableHeadingColor">
|
|
<TD COLSPAN=1><FONT SIZE="+2">
|
|
<B>Method Detail</B></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="parseLong(calypso.util.ByteBuf, boolean)"><!-- --></A><H3>
|
|
parseLong</H3>
|
|
<PRE>
|
|
public static long <B>parseLong</B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> buf,
|
|
boolean default_to_gmt)</PRE>
|
|
<DL>
|
|
<DD>This parses a time/date string into a Time object.
|
|
If it can't be parsed, -1 is returned.
|
|
|
|
<P>Many formats are handled, including:
|
|
|
|
<P><UL>
|
|
<LI> <TT> 14 Apr 89 03:20:12 </TT>
|
|
<LI> <TT> 14 Apr 89 03:20 GMT </TT>
|
|
<LI> <TT> Fri, 17 Mar 89 4:01:33 </TT>
|
|
<LI> <TT> Fri, 17 Mar 89 4:01 GMT </TT>
|
|
<LI> <TT> Mon Jan 16 16:12 PDT 1989 </TT>
|
|
<LI> <TT> Mon Jan 16 16:12 +0130 1989 </TT>
|
|
<LI> <TT> 6 May 1992 16:41-JST (Wednesday) </TT>
|
|
<LI> <TT> 22-AUG-1993 10:59:12.82 </TT>
|
|
<LI> <TT> 22-AUG-1993 10:59pm </TT>
|
|
<LI> <TT> 22-AUG-1993 12:59am </TT>
|
|
<LI> <TT> 22-AUG-1993 12:59 PM </TT>
|
|
<LI> <TT> Friday, August 04, 1995 3:54 PM </TT>
|
|
<LI> <TT> 06/21/95 04:24:34 PM </TT>
|
|
<LI> <TT> 20/06/95 21:07 </TT>
|
|
<LI> <TT> 95-06-08 19:32:48 EDT </TT>
|
|
</UL>
|
|
|
|
<P> But note that <TT>6/5/95</TT> is ambiguous, since it's not obvious
|
|
which is the day and which is the month. (<TT>6/13/95</TT> is not
|
|
ambiguous, however.)<DD><DL>
|
|
<DT><B>Parameters:</B><DD><CODE>buf</CODE> - 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.<DD><CODE>default_to_gmt</CODE> - 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.<DT><B>Returns:</B><DD>Microseconds since Jan 1, 1900, GMT.
|
|
You can pass this to <TT>new Date(long)</TT>.
|
|
Returns -1 if the string is unparsable
|
|
(no other negative value will ever be returned;
|
|
dates before the Epoch are not handled.)</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="parseLong(byte[], int, int, boolean)"><!-- --></A><H3>
|
|
parseLong</H3>
|
|
<PRE>
|
|
public static long <B>parseLong</B>(byte[] string,
|
|
int start,
|
|
int end,
|
|
boolean default_to_gmt)</PRE>
|
|
<DL>
|
|
<DD>The same, but takes a byte array and a region within it, instead
|
|
of a ByteBuf.</DL>
|
|
<HR>
|
|
|
|
<A NAME="parseLong(calypso.util.ByteBuf)"><!-- --></A><H3>
|
|
parseLong</H3>
|
|
<PRE>
|
|
public static long <B>parseLong</B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> string)</PRE>
|
|
<DL>
|
|
<DD>The same, but assumes GMT is the default timezone.</DL>
|
|
<HR>
|
|
|
|
<A NAME="parseDate(calypso.util.ByteBuf, boolean)"><!-- --></A><H3>
|
|
parseDate</H3>
|
|
<PRE>
|
|
public static java.util.Date <B>parseDate</B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> string,
|
|
boolean default_to_gmt)</PRE>
|
|
<DL>
|
|
<DD>Like parseLong(), but returns a new Date object instead.</DL>
|
|
<HR>
|
|
|
|
<A NAME="parseDate(calypso.util.ByteBuf)"><!-- --></A><H3>
|
|
parseDate</H3>
|
|
<PRE>
|
|
public static java.util.Date <B>parseDate</B>(<A HREF="../../calypso/util/ByteBuf.html">ByteBuf</A> string)</PRE>
|
|
<DL>
|
|
<DD>The same, but assumes GMT is the default timezone.</DL>
|
|
<HR>
|
|
|
|
<A NAME="UTC(int, int, int, int, int, int)"><!-- --></A><H3>
|
|
UTC</H3>
|
|
<PRE>
|
|
public static long <B>UTC</B>(int year,
|
|
int month,
|
|
int date,
|
|
int hour,
|
|
int min,
|
|
int sec)</PRE>
|
|
<DL>
|
|
<DD>Composes the given date into a number suitable for passing to
|
|
<TT>new Date(n)</TT>. This is the number of milliseconds
|
|
past the Epoch.</DL>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<HR>
|
|
|
|
<!-- ========== START OF NAVBAR ========== -->
|
|
<A NAME="navbar_bottom"><!-- --></A>
|
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
|
|
<TR>
|
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1">
|
|
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
|
|
<TR ALIGN="center" VALIGN="top">
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> <FONT ID="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
|
</TR>
|
|
</TABLE>
|
|
</TD>
|
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
|
</EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../calypso/util/MemoryMonitor.html"><B>PREV CLASS</B></A>
|
|
<A HREF="../../calypso/util/NullEnumeration.html"><B>NEXT CLASS</B></A></FONT></TD>
|
|
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>
|
|
<A HREF="NetworkDate.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
|
|
SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
<!-- =========== END OF NAVBAR =========== -->
|
|
|
|
<HR>
|
|
|
|
</BODY>
|
|
</HTML>
|