    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class java.sql.Timestamp

    java.lang.Object
       |
       +----java.util.Date
               |
               +----java.sql.Timestamp

public class Timestamp
extends Date

This class is a thin wrapper around java.util.Date that allows JDBC to identify this as a SQL TIMESTAMP value. It adds the ability to hold the SQL TIMESTAMP nanos value and provides formatting and parsing operations to support the JDBC escape syntax for timestamp values.

Note: This type is a composite of a java.util.Date and a separate nanos value. Only integral seconds are stored in the java.util.Date component. The fractional seconds - the nanos - are separate. The getTime method will only return 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 getTime value. Also note that the hashcode() method uses the underlying java.util.Data implementation and therefore does not include nanos in its computation.

##

Timestamp(int, int, int, int, int, int, int)
  Construct a Timestamp Object
Timestamp(long)
  Construct a Timestamp using a milliseconds time value.

##

after(Timestamp)
  Is this timestamp later than the timestamp argument?
before(Timestamp)
  Is this timestamp earlier than the timestamp argument?
equals(Timestamp)
  Test Timestamp values for equality
getNanos()
  Get the Timestamp's nanos value
setNanos(int)
  Set the Timestamp's nanos value
toString()
  Format a timestamp in JDBC timestamp escape format
valueOf(String)
  Convert a string in JDBC timestamp escape format to a Timestamp value

##

Timestamp

     public Timestamp(int year,
                      int month,
                      int date,
                      int hour,
                      int minute,
                      int second,
                      int nano)

  Construct a Timestamp Object

  Parameters:
    year - year-1900
    month - 0 to 11
    day - 1 to 31
    hour - 0 to 23
    minute - 0 to 59
    second - 0 to 59
    nano - 0 to 999,999,999

Timestamp

     public Timestamp(long time)

  Construct a Timestamp using a milliseconds time value. The integral seconds are stored in the underlying date value; the fractional seconds are stored in the nanos value.

  Parameters:
    time - milliseconds since January 1, 1970, 00:00:00 GMT

##

valueOf

     public static Timestamp valueOf(String s)

  Convert a string in JDBC timestamp escape format to a Timestamp value

  Parameters:
    s - timestamp in format "yyyy-mm-dd hh:mm:ss.fffffffff"
  Returns:
    corresponding Timestamp

toString

     public String toString()

  Format a timestamp in JDBC timestamp escape format

  Returns:
    a String in yyyy-mm-dd hh:mm:ss.fffffffff format
  Overrides:
    toString in class Date

getNanos

     public int getNanos()

  Get the Timestamp's nanos value

  Returns:
    the Timestamp's fractional seconds component

setNanos

     public void setNanos(int n)

  Set the Timestamp's nanos value

  Parameters:
    n - the new fractional seconds component

equals

     public boolean equals(Timestamp ts)

  Test Timestamp values for equality

  Parameters:
    ts - the Timestamp value to compare with

before

     public boolean before(Timestamp ts)

  Is this timestamp earlier than the timestamp argument?

  Parameters:
    ts - the Timestamp value to compare with

after

     public boolean after(Timestamp ts)

  Is this timestamp later than the timestamp argument?

  Parameters:
    ts - the Timestamp value to compare with

    All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.