📄 date.html
字号:
<A NAME="after(java.util.Date)"><!-- --></A><H3>after</H3><PRE>public boolean <B>after</B>(<A HREF="../../java/util/Date.html">Date</A> when)</PRE><DL><DD>Tests if this date is after the specified date.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>when</CODE> - a date.<DT><B>Returns:</B><DD><code>true</code> if and only if the instant represented by this <tt>Date</tt> object is strictly later than the instant represented by <tt>when</tt>; <code>false</code> otherwise.</DL></DD></DL><HR><A NAME="equals(java.lang.Object)"><!-- --></A><H3>equals</H3><PRE>public boolean <B>equals</B>(<A HREF="../../java/lang/Object.html">Object</A> obj)</PRE><DL><DD>Compares two dates for equality. The result is <code>true</code> if and only if the argument is not <code>null</code> and is a <code>Date</code> object that represents the same point in time, to the millisecond, as this object. <p> Thus, two <code>Date</code> objects are equal if and only if the <code>getTime</code> method returns the same <code>long</code> value for both.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to compare with.<DT><B>Returns:</B><DD><code>true</code> if the objects are the same; <code>false</code> otherwise.<DT><B>See Also: </B><DD><A HREF="../../java/util/Date.html#getTime()"><CODE>getTime()</CODE></A></DL></DD></DL><HR><A NAME="compareTo(java.util.Date)"><!-- --></A><H3>compareTo</H3><PRE>public int <B>compareTo</B>(<A HREF="../../java/util/Date.html">Date</A> anotherDate)</PRE><DL><DD>Compares two Dates for ordering.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>anotherDate</CODE> - the <code>Date</code> to be compared.<DT><B>Returns:</B><DD>the value <code>0</code> if the argument Date is equal to this Date; a value less than <code>0</code> if this Date is before the Date argument; and a value greater than <code>0</code> if this Date is after the Date argument.<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="compareTo(java.lang.Object)"><!-- --></A><H3>compareTo</H3><PRE>public int <B>compareTo</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Compares this Date to another Object. If the Object is a Date, this function behaves like <code>compareTo(Date)</code>. Otherwise, it throws a <code>ClassCastException</code> (as Dates are comparable only to other Dates).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/lang/Comparable.html#compareTo(java.lang.Object)">compareTo</A></CODE> in interface <CODE><A HREF="../../java/lang/Comparable.html">Comparable</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - the <code>Object</code> to be compared.<DT><B>Returns:</B><DD>the value <code>0</code> if the argument is a Date equal to this Date; a value less than <code>0</code> if the argument is a Date after this Date; and a value greater than <code>0</code> if the argument is a Date before this Date.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if the argument is not a <code>Date</code>.<DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A></DL></DD></DL><HR><A NAME="hashCode()"><!-- --></A><H3>hashCode</H3><PRE>public int <B>hashCode</B>()</PRE><DL><DD>Returns a hash code value for this object. The result is the exclusive OR of the two halves of the primitive <tt>long</tt> value returned by the <A HREF="../../java/util/Date.html#getTime()"><CODE>getTime()</CODE></A> method. That is, the hash code is the value of the expression: <blockquote><pre> (int)(this.getTime()^(this.getTime() >>> 32))</pre></blockquote><DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#hashCode()">hashCode</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a hash code value for this object.</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Converts this <code>Date</code> object to a <code>String</code> of the form: <blockquote><pre> dow mon dd hh:mm:ss zzz yyyy</pre></blockquote> where:<ul> <li><tt>dow</tt> is the day of the week (<tt>Sun, Mon, Tue, Wed, Thu, Fri, Sat</tt>). <li><tt>mon</tt> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec</tt>). <li><tt>dd</tt> is the day of the month (<tt>01</tt> through <tt>31</tt>), as two decimal digits. <li><tt>hh</tt> is the hour of the day (<tt>00</tt> through <tt>23</tt>), as two decimal digits. <li><tt>mm</tt> is the minute within the hour (<tt>00</tt> through <tt>59</tt>), as two decimal digits. <li><tt>ss</tt> is the second within the minute (<tt>00</tt> through <tt>61</tt>, as two decimal digits. <li><tt>zzz</tt> is the time zone (and may reflect daylight savings time). Standard time zone abbreviations include those recognized by the method <tt>parse</tt>. If time zone informationi is not available, then <tt>zzz</tt> is empty - that is, it consists of no characters at all. <li><tt>yyyy</tt> is the year, as four decimal digits. </ul><DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this date.<DT><B>See Also: </B><DD><A HREF="../../java/util/Date.html#toLocaleString()"><CODE>toLocaleString()</CODE></A>, <A HREF="../../java/util/Date.html#toGMTString()"><CODE>toGMTString()</CODE></A></DL></DD></DL><HR><A NAME="toLocaleString()"><!-- --></A><H3>toLocaleString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toLocaleString</B>()</PRE><DL><DD><B>Deprecated.</B> <I>As of JDK version 1.1, replaced by <code>DateFormat.format(Date date)</code>.</I><P><DD>Creates a string representation of this <tt>Date</tt> object in an implementation-dependent form. The intent is that the form should be familiar to the user of the Java application, wherever it may happen to be running. The intent is comparable to that of the "<code>%c</code>" format supported by the <code>strftime()</code> function of ISO C.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this date, using the locale conventions.<DT><B>See Also: </B><DD><A HREF="../../java/text/DateFormat.html"><CODE>DateFormat</CODE></A>, <A HREF="../../java/util/Date.html#toString()"><CODE>toString()</CODE></A>, <A HREF="../../java/util/Date.html#toGMTString()"><CODE>toGMTString()</CODE></A></DL></DD></DL><HR><A NAME="toGMTString()"><!-- --></A><H3>toGMTString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toGMTString</B>()</PRE><DL><DD><B>Deprecated.</B> <I>As of JDK version 1.1, replaced by <code>DateFormat.format(Date date)</code>, using a GMT <code>TimeZone</code>.</I><P><DD>Creates a string representation of this <tt>Date</tt> object of the form: <blockquote<pre> d mon yyyy hh:mm:ss GMT</pre></blockquote> where:<ul> <li><i>d</i> is the day of the month (<tt>1</tt> through <tt>31</tt>), as one or two decimal digits. <li><i>mon</i> is the month (<tt>Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec</tt>). <li><i>yyyy</i> i sthe year, as four decimal digits. <li><i>hh</i> is the hour of the day (<tt>00</tt> through <tt>23</tt>), as two decimal digits. <li><i>mm</i> is the minute within the hour (<tt>00</tt> through <tt>59</tt>), as two decimal digits. <li><i>ss</i> is the second within the minute (<tt>00</tt> through <tt>61</tt>), as two decimal digits. <li><i>GMT</i> is exactly the ASCII letters "<tt>GMT</tt>" to indicate Greenwich Mean Time. </ul><p> The result does not depend on the local time zone.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this date, using the Internet GMT conventions.<DT><B>See Also: </B><DD><A HREF="../../java/text/DateFormat.html"><CODE>DateFormat</CODE></A>, <A HREF="../../java/util/Date.html#toString()"><CODE>toString()</CODE></A>, <A HREF="../../java/util/Date.html#toLocaleString()"><CODE>toLocaleString()</CODE></A></DL></DD></DL><HR><A NAME="getTimezoneOffset()"><!-- --></A><H3>getTimezoneOffset</H3><PRE>public int <B>getTimezoneOffset</B>()</PRE><DL><DD><B>Deprecated.</B> <I>As of JDK version 1.1, replaced by <code>Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)</code>.</I><P><DD>Returns the offset, measured in minutes, for the local time zone relative to UTC that is appropriate for the time represented by this <tt>Date</tt> object. <p> For example, in Massachusetts, five time zones west of Greenwich: <blockquote><pre> new Date(96, 1, 14).getTimezoneOffset() returns 300</pre></blockquote> because on February 14, 1996, standard time (Eastern Standard Time) is in use, which is offset five hours from UTC; but: <blockquote><pre> new Date(96, 5, 1).getTimezoneOffset() returns 240</pre></blockquote> because on May 1, 1996, daylight savings time (Eastern Daylight Time) is in use, which is offset only four hours from UTC.<p> This method produces teh same result as if it computed: <blockquote><pre> (this.getTime() - UTC(this.getYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds())) / (60 * 1000) </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the time-zone offset, in minutes, for the current locale.<DT><B>See Also: </B><DD><A HREF="../../java/util/Calendar.html"><CODE>Calendar</CODE></A>, <A HREF="../../java/util/TimeZone.html"><CODE>TimeZone</CODE></A></DL></DD></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" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Date.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/util/Collections.html"><B>PREV CLASS</B></A> <A HREF="../../java/util/Dictionary.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Date.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -