java.sql
public class Timestamp extends Date
java.util.Date
as
the java.sql.Date
and java.sql.Time
classes are.Constructor and Description |
---|
Timestamp(int year,
int month,
int day,
int hour,
int minute,
int second,
int nanos)
Deprecated.
|
Timestamp(long date)
This method initializes a new instance of this class with the
specified time value representing the number of milliseconds since
Jan 1, 1970 at 12:00 midnight GMT.
|
Modifier and Type | Method and Description |
---|---|
boolean |
after(Timestamp ts)
This methods tests whether this object is later than the specified
object.
|
boolean |
before(Timestamp ts)
This methods tests whether this object is earlier than the specified
object.
|
int |
compareTo(Date obj)
Compares this
Timestamp to another one. |
int |
compareTo(Timestamp ts)
Compares this
Timestamp to another one. |
boolean |
equals(Object obj)
This method these the specified
Object for equality
against this object. |
boolean |
equals(Timestamp ts)
This method tests the specified timestamp for equality against this
object.
|
int |
getNanos()
This method returns the nanosecond value for this object.
|
long |
getTime()
Return the value of this Timestamp as the number of milliseconds
since Jan 1, 1970 at 12:00 midnight GMT.
|
void |
setNanos(int nanos)
This method sets the nanosecond value for this object.
|
String |
toString()
This method returns this date in JDBC format.
|
static Timestamp |
valueOf(String str)
This method returns a new instance of this class by parsing a
date in JDBC format into a Java date.
|
after, before, clone, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toLocaleString, UTC
public Timestamp(int year, int month, int day, int hour, int minute, int second, int nanos)
year
- The year for this Timestamp (year - 1900)month
- The month for this Timestamp (0-11)day
- The day for this Timestamp (1-31)hour
- The hour for this Timestamp (0-23)minute
- The minute for this Timestamp (0-59)second
- The second for this Timestamp (0-59)nanos
- The nanosecond value for this Timestamp (0 to 999,999,9999)public Timestamp(long date)
date
- The time value to intialize this Time
to.public static Timestamp valueOf(String str)
str
- The string to parse.java.sql.Timestamp
value.public long getTime()
public String toString()
toString
in class Date
Date.parse(String)
,
DateFormat
public int getNanos()
public void setNanos(int nanos)
nanos
- The nanosecond value for this object.public boolean before(Timestamp ts)
ts
- The other Timestamp
to test against.true
if this object is earlier than the other object,
false
otherwise.public boolean after(Timestamp ts)
ts
- The other Timestamp
to test against.true
if this object is later than the other object,
false
otherwise.public boolean equals(Object obj)
Object
for equality
against this object. This will be true if an only if the specified
object is an instance of Timestamp
and has the same
time value fields.equals
in class Date
obj
- The object to test against for equality.true
if the specified object is equal to this
object, false
otherwise.Object.hashCode()
public boolean equals(Timestamp ts)
null
and contains all the same time value fields
as this object.ts
- The Timestamp
to test against for equality.true
if the specified object is equal to this
object, false
otherwise.public int compareTo(Timestamp ts)
Timestamp
to another one.ts
- The other Timestamp.0
, if both Timestamp
's represent exactly
the same date, a negative value if this Timestamp
is
before the specified Timestamp
and a positive value
otherwise.public int compareTo(Date obj)
Timestamp
to another one. This behaves like
compareTo(Timestamp)
, but it may throw a
ClassCastException
, if the specified object is not of type
Timestamp
.compareTo
in interface Comparable<Date>
compareTo
in class Date
obj
- The object to compare with.0
, if both Timestamp
's represent exactly
the same date, a negative value if this Timestamp
is
before the specified Timestamp
and a positive value
otherwise.ClassCastException
- if obj is not of type Timestamp.compareTo(Timestamp)