toInstant(): This method is available in java.util.Calendar class of Java.
Syntax:
Instant java.util.Calendar.toInstant()
This method converts this object to an Instant.
Parameters: NA
Returns: the instant representing the same point on the timeline.
Returns: NA
Approach
Java
import java.util.Calendar;public class CalendartoInstant {public static void main(String[] args) {// create a calendarCalendar calendar = Calendar.getInstance();System.out.println(calendar.toInstant());}}
Output:
2022-01-23T17:55:34.818Z
No comments:
Post a Comment