Java TimestampTimestamp provides formatting and parsing operations to support JDBC escape syntax. It also adds the ability to hold the SQL TIMESTAMP fractional seconds value. MethodsMethods | Description |
---|
after() | Returns Boolean value true if this Timestamp object comes later than given Timestamp object. | before() | Returns Boolean value true if this Timestamp object comes earlier than given Timestamp object. | compareTo() | Compares this Timestamp object to the given Timestamp object or to the given date object | equals() | Returns a Boolean value true if this Timestamp object is equal specified object or to the given Timestamp object . | from() | Obtains an instance of Timestamp from an Instant object | getNanos() | Fetches the Timestamp object's nanos value | getTime() | Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT | hashCode() | Returns a hash code value for this object | setNanos() | Sets a nanos value for the specified integer value | setTime() | Sets this class's object to indicate a point in time (milliseconds) after January 1, 1970 00:00:00 GMT | toInstant() | Coverts the Timespan object to an Instant which represents the same point on the time-line as this Timestamp | toLocalDateTime() | Converts this Timespan object to a LocalDateTime which represents the same date-time value as this Timestamp | toString() | Converts the Timespan object in JDBC timestamp escape format | valueOf() | Converts the string object to Timestamp value or obtains an instance of Timestamp from a LocalDateTime object. |
Example 1Output: 1. from() method will return 2018-09-06 12:42:53.885
2. value of Timestamp : 2018-09-01 09:01:15.0
3. Fractional seconds component : 0
4. Boolean value returned : true
Example 2Output: Timestamp : 2018-09-01 09:01:15.0
1. Milliseconds : 1535772675000
2. Hash code : -1825617187
3. Timestamp after setting nanos : 2018-09-01 09:01:15.000054647
4. Instant Timespan : 2018-09-01T03:31:15.000054647Z
|