Java Timestamp toInstant() Method

The toInstant() method of Timestamp class coverts the Timespan object to an Instant which represents the same point on the time-line as this Timestamp.

Syntax

Parameters

NA

Returns

The toInstant () method of Timestamp class returns an Instant which represents the same point on the time-line as this Timestamp.

Overrides

The toInstant () method of Timestamp class overrides:

toInstant () method in class Date

Example 1

Output:

Timestamp : 2018-09-01 09:01:15.0
Instant Timespan : 2018-09-01T03:31:15Z

Example 2

Output:

Timestamp : 2018-09-06 11:59:02.683
Current instant Timespan : 2018-09-06T06:29:02.683Z