toZonedDateTime(): This method is available in java.util.GregorianCalendar class of Java.
Syntax:
ZonedDateTime java.util.GregorianCalendar.toZonedDateTime()
This method converts this object to a ZonedDateTime that represents the same point on the time-line as this GregorianCalendar.
Parameters: NA
Returns: a zoned date-time representing the same point on the timeline as this gregorian calendar.
Exceptions: NA
Approach
Java
import java.util.GregorianCalendar;public class GregorianCalendartoZonedDateTime {public static void main(String[] args) {GregorianCalendar cal = new GregorianCalendar();System.out.println(cal.toZonedDateTime());}}
Output:
2022-02-18T21:33:10.883+05:30[Asia/Calcutta]
No comments:
Post a Comment