Name

Timestamp

Synopsis

Class Name: java.sql.Timestamp

Superclass: java.util.Date

Immediate Subclasses: None

Interfaces Implemented: None

Availability: JDK 1.1

Description

This class serves as a SQL representation of the Java Date class specifically designed to serve as a SQL TIMESTAMP. It also provides the ability to hold nanoseconds as required by SQL TIMESTAMP values. You should keep in mind that this class uses the java.util.Date version of hashcode( ). This means that two timestamps that differ only by nanoseconds will have identical hashcode() return values.

Class Summary

public class Timestamp extends java.util.Date {
    static public Timestamp valueOf(String s);
    #public Timestamp(int year, int month, int date, 
        int hour, int minute, int second, int nano);
    public Timestamp(long time);
    public boolean after(Timestamp t);
    public boolean before(Timestamp t);
    public boolean equals(Timestamp t);
    public int getNanos( );
    public void setNanos(int n);
    public String toString( );
}

Object Constructors

Timestamp( )

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

This constructor creates a new Timestamp object. The first prototype constructs a Timestamp for the year, month, date, hour, minute, second, and nanosecond specified. The second prototype constructs one based on the number of seconds since January 1, 1970, 12:00:00 ...

Get Database Programming with JDBC & Java, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.