Calendar getTime() Method in Java with Examples
The getTime() method in Calendar class is used to return an object resembling the Date that is represented by this Calendar’s time value.
public final Date getTime()
Parameters: The method does not take any parameters.
Return Value: The method returns the Date, represented by this Calendar.
Below programs illustrate the working of getTime() Method of Calendar class:
The Current Time is: Wed Feb 20 14:40:37 UTC 2019 The upcoming time is: Wed Feb 20 14:40:47 UTC 2019
The Current Time is: Wed Feb 20 14:40:50 UTC 2019 The upcoming time is: Wed Feb 20 14:40:55 UTC 2019
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.