getTime(): This method is available in java.util.GregorianCalendar class of Java.
Syntax:
Date java.util.Calendar.getTime()
This method returns a Date object representing this Calendar's time value.
Parameters: NA
Returns: a Date representing the time value.
Exceptions: NA
Approach
Java
import java.util.GregorianCalendar;public class GregorianCalendargetTime {public static void main(String[] args) {GregorianCalendar cal = new GregorianCalendar();System.out.println(cal.getTime());}}
Output:
Sun Feb 06 21:28:42 IST 2022
No comments:
Post a Comment