Class java.sql.Timestamp
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 extends the standard sun.util.date class with nanos. This lets it represent SQL timestamps.

Note: The granularity of sub-second timestamp precision may vary between database fields, and stored values will get rounded to the field's internal precision.


Constructor Index

 o Timestamp(int, int, int, int, int, int, int)
Construct a Timestamp

Method Index

 o equals(Timestamp)
Test Timestamp values for equality
 o getNanos()
Get the Timestamp's nanos value
 o setNanos(int)
Set the Timestamp's nanos value
 o toString()
Format a Timestamp as yyyy-mm-dd hh:mm:ss.f...
 o valueOf(String)
Convert a formatted string to a Timestamp value

Constructors

 o Timestamp
  public Timestamp(int year,
                   int month,
                   int date,
                   int hour,
                   int minute,
                   int second,
                   int nano)
Construct a Timestamp
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

Methods

 o valueOf
  public static Timestamp valueOf(String s)
Convert a formatted string to a Timestamp value
Parameters:
s - timestamp in format "yyyy-mm-dd hh:mm:ss.f"
Returns:
corresponding Date
 o toString
  public String toString()
Format a Timestamp as yyyy-mm-dd hh:mm:ss.f...
Returns:
a formatted timestamp String
Overrides:
toString in class Date
 o getNanos
  public int getNanos()
Get the Timestamp's nanos value
Returns:
the Timestamp's fractional seconds component
 o setNanos
  public void setNanos(int n)
Set the Timestamp's nanos value
Parameters:
n - the new fractional seconds component
 o equals
  public boolean equals(Timestamp ts)
Test Timestamp values for equality
Parameters:
ts - the Timestamp value to compare with

All Packages  Class Hierarchy  This Package  Previous  Next  Index