Java Calendar toInstant() MethodThe toInstant() method of the Calendar class is used to convert the current object to an instant, and this instant represents same time as the current calendar object. SyntaxParameterDoes not accept any parameter. ReturnsReturns the instant representing same time. ThrowsDoes not throw Exception. Example 1Output: Past calendar : Sat Aug 18 12:07:13 PDT 2018 calendar after using toInstant() : 2018-08-18T19:07:13.206Z Example 2Output: cal Sat Aug 18 12:14:53 PDT 2018 cal.toInstant() : 2022-11-12T02:20:53.084Z Next TopicJava-calendar-tostring-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India