📄 timestamp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:36:32 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class Timestamp</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" CLASS="NavBarCell1"><A NAME="navbar_top_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/Timestamp.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/sql/Time.html"><B>PREV CLASS</B></A> <A HREF="../../java/sql/Types.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="Timestamp.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><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.sql</FONT><BR>Class Timestamp</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../../java/util/Date.html">java.util.Date</A> | +--<B>java.sql.Timestamp</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../java/lang/Cloneable.html">Cloneable</A>, <A HREF="../../java/lang/Comparable.html">Comparable</A>, <A HREF="../../java/io/Serializable.html">Serializable</A></DD></DL><HR><DL><DT>public class <B>Timestamp</B><DT>extends <A HREF="../../java/util/Date.html">Date</A></DL><P><P>A thin wrapper around <code>java.util.Date</code> that allows the JDBC API to identify this as an SQL <code>TIMESTAMP</code> value. It adds the ability to hold the SQL <code>TIMESTAMP</code> nanos value and provides formatting and parsing operations to support the JDBC escape syntax for timestamp values. <P><B>Note:</B> This type is a composite of a <code>java.util.Date</code> and a separate nanoseconds value. Only integral seconds are stored in the <code>java.util.Date</code> component. The fractional seconds - the nanos - are separate. The <code>getTime</code> method will return only integral seconds. If a time value that includes the fractional seconds is desired, you must convert nanos to milliseconds (nanos/1000000) and add this to the <code>getTime</code> value. The <code>Timestamp.equals(Object)</code> method never returns <code>true</code> when passed a value of type <code>java.util.Date</code> because the nanos component of a date is unknown. As a result, the <code>Timestamp.equals(Object)</code> method is not symmetric with respect to the <code>java.util.Date.equals(Object)</code> method. Also, the <code>hashcode</code> method uses the underlying <code>java.util.Data</code> implementation and therefore does not include nanos in its computation. Due to the differences between the <code>Timestamp</code> class and the <code>java.util.Date</code> class mentioned above, it is recommended that code not view <code>Timestamp</code> values generically as an instance of <code>java.util.Date</code>. The inheritance relationship between <code>Timestamp</code> and <code>java.util.Date</code> really denotes implementation inheritance, and not type inheritance.<P><DL><DT><B>See Also: </B><DD><A HREF="../../serialized-form.html#java.sql.Timestamp">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#Timestamp(int, int, int, int, int, int, int)">Timestamp</A></B>(int year, int month, int date, int hour, int minute, int second, int nano)</CODE><BR> <B>Deprecated.</B> <I>instead use the constructor <code>Timestamp(long millis)</code></I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#Timestamp(long)">Timestamp</A></B>(long time)</CODE><BR> Constructs a <code>Timestamp</code> object using a milliseconds time value.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#after(java.sql.Timestamp)">after</A></B>(<A HREF="../../java/sql/Timestamp.html">Timestamp</A> ts)</CODE><BR> Indicates whether this <code>Timestamp</code> object is later than the given <code>Timestamp</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#before(java.sql.Timestamp)">before</A></B>(<A HREF="../../java/sql/Timestamp.html">Timestamp</A> ts)</CODE><BR> Indicates whether this <code>Timestamp</code> object is earlier than the given <code>Timestamp</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#equals(java.lang.Object)">equals</A></B>(<A HREF="../../java/lang/Object.html">Object</A> ts)</CODE><BR> Tests to see if this <code>Timestamp</code> object is equal to the given object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#equals(java.sql.Timestamp)">equals</A></B>(<A HREF="../../java/sql/Timestamp.html">Timestamp</A> ts)</CODE><BR> Tests to see if this <code>Timestamp</code> object is equal to the given <code>Timestamp</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#getNanos()">getNanos</A></B>()</CODE><BR> Gets this <code>Timestamp</code> object's <code>nanos</code> value.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#setNanos(int)">setNanos</A></B>(int n)</CODE><BR> Sets this <code>Timestamp</code> object's <code>nanos</code> field to the given value.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#toString()">toString</A></B>()</CODE><BR> Formats a timestamp in JDBC timestamp escape format.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/sql/Timestamp.html">Timestamp</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/Timestamp.html#valueOf(java.lang.String)">valueOf</A></B>(<A HREF="../../java/lang/String.html">String</A> s)</CODE><BR> Converts a <code>String</code> object in JDBC timestamp escape format to a <code>Timestamp</code> value.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.util.Date"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.util.<A HREF="../../java/util/Date.html">Date</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/util/Date.html#after(java.util.Date)">after</A>, <A HREF="../../java/util/Date.html#before(java.util.Date)">before</A>, <A HREF="../../java/util/Date.html#clone()">clone</A>, <A HREF="../../java/util/Date.html#compareTo(java.util.Date)">compareTo</A>, <A HREF="../../java/util/Date.html#compareTo(java.lang.Object)">compareTo</A>, <A HREF="../../java/util/Date.html#getDate()">getDate</A>, <A HREF="../../java/util/Date.html#getDay()">getDay</A>, <A HREF="../../java/util/Date.html#getHours()">getHours</A>, <A HREF="../../java/util/Date.html#getMinutes()">getMinutes</A>, <A HREF="../../java/util/Date.html#getMonth()">getMonth</A>, <A HREF="../../java/util/Date.html#getSeconds()">getSeconds</A>, <A HREF="../../java/util/Date.html#getTime()">getTime</A>, <A HREF="../../java/util/Date.html#getTimezoneOffset()">getTimezoneOffset</A>, <A HREF="../../java/util/Date.html#getYear()">getYear</A>, <A HREF="../../java/util/Date.html#hashCode()">hashCode</A>, <A HREF="../../java/util/Date.html#parse(java.lang.String)">parse</A>, <A HREF="../../java/util/Date.html#setDate(int)">setDate</A>, <A HREF="../../java/util/Date.html#setHours(int)">setHours</A>, <A HREF="../../java/util/Date.html#setMinutes(int)">setMinutes</A>, <A HREF="../../java/util/Date.html#setMonth(int)">setMonth</A>, <A HREF="../../java/util/Date.html#setSeconds(int)">setSeconds</A>, <A HREF="../../java/util/Date.html#setTime(long)">setTime</A>, <A HREF="../../java/util/Date.html#setYear(int)">setYear</A>, <A HREF="../../java/util/Date.html#toGMTString()">toGMTString</A>, <A HREF="../../java/util/Date.html#toLocaleString()">toLocaleString</A>, <A HREF="../../java/util/Date.html#UTC(int, int, int, int, int, int)">UTC</A></CODE></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -