src/java.sql/share/classes/java/sql/Timestamp.java

Print this page




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.sql;
  27 
  28 import java.time.Instant;
  29 import java.time.LocalDateTime;
  30 import sun.misc.SharedSecrets;
  31 import sun.misc.JavaLangAccess;
  32 
  33 /**
  34  * <P>A thin wrapper around {@code java.util.Date} that allows
  35  * the JDBC API to identify this as an SQL {@code TIMESTAMP} value.
  36  * It adds the ability
  37  * to hold the SQL {@code TIMESTAMP} fractional seconds value, by allowing
  38  * the specification of fractional seconds to a precision of nanoseconds.
  39  * A Timestamp also provides formatting and
  40  * parsing operations to support the JDBC escape syntax for timestamp values.
  41  *
  42  * <p>The precision of a Timestamp object is calculated to be either:
  43  * <ul>
  44  * <li>{@code 19 }, which is the number of characters in yyyy-mm-dd hh:mm:ss
  45  * <li> {@code  20 + s }, which is the number
  46  * of characters in the yyyy-mm-dd hh:mm:ss.[fff...] and {@code s} represents  the scale of the given Timestamp,
  47  * its fractional seconds precision.
  48  *</ul>
  49  *
  50  * <P><B>Note:</B> This type is a composite of a {@code java.util.Date} and a
  51  * separate nanoseconds value. Only integral seconds are stored in the




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.sql;
  27 
  28 import java.time.Instant;
  29 import java.time.LocalDateTime;
  30 import jdk.internal.misc.SharedSecrets;
  31 import jdk.internal.misc.JavaLangAccess;
  32 
  33 /**
  34  * <P>A thin wrapper around {@code java.util.Date} that allows
  35  * the JDBC API to identify this as an SQL {@code TIMESTAMP} value.
  36  * It adds the ability
  37  * to hold the SQL {@code TIMESTAMP} fractional seconds value, by allowing
  38  * the specification of fractional seconds to a precision of nanoseconds.
  39  * A Timestamp also provides formatting and
  40  * parsing operations to support the JDBC escape syntax for timestamp values.
  41  *
  42  * <p>The precision of a Timestamp object is calculated to be either:
  43  * <ul>
  44  * <li>{@code 19 }, which is the number of characters in yyyy-mm-dd hh:mm:ss
  45  * <li> {@code  20 + s }, which is the number
  46  * of characters in the yyyy-mm-dd hh:mm:ss.[fff...] and {@code s} represents  the scale of the given Timestamp,
  47  * its fractional seconds precision.
  48  *</ul>
  49  *
  50  * <P><B>Note:</B> This type is a composite of a {@code java.util.Date} and a
  51  * separate nanoseconds value. Only integral seconds are stored in the