public class Timestamp extends Date
This class extends the standard java.util.date to represent SQL TIMESTAMP types. It supports subsecond precision and the JDBC escape syntax for time values.
Timestamp
public Timestamp(int year, int month, int date, int hour, int minute, int second, int nano)
This constructs a Timestamp object.
Parameters:
year: | The year minus 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)
This constructs a Timestamp object using a time value in milliseconds.
Parameters:
time: | The milliseconds since January 1, 1970, 00:00:00 GMT |
compareTo
public int compareTo(Timestamp ts)
This compares two Timestamps for ordering.
Parameters:
ts: | The Timestamp to be compared. |
Returns: 0 if the timestamp equals ts; a negative value if the timestamp is anterior to ts; a positive value if the timestamp is posterior to ts
equals
public boolean equals(Timestamp ts)
This compares the current Timestamp object with another.
Parameters:
ts: | The Timestamp value to compare with |
Returns: true if they are equal
getNanos
public int getNanos()
This gets the Timestamp’s nanosecond value.
Returns: The Timestamp’s nanosecond value
setNanos
public void setNanos(int n)
This sets the Timestamp’s nanosecond value.
Parameters:
n: | The Timestamp’s nanosecond value |
toString
public String toString()
This converts a Timestamp to YYYY-MM-DD HH:MM:SS.F format.
Returns: A YYYY-MM-DD HH:MM:SS.F formatted timestamp String
valueOf
public static Timestamp valueOf(String s)
This converts a YYYY-MM-DD HH:MM:SS.F formatted string to a Timestamp value.
Parameters:
s: | The timestamp formatted as YYYY-MM-DD HH:MM:SS.F |
Returns: A Timestamp value