Calendar class getTime() method example
Returns a Date object representing this Calendar's time value
Calendar class getTime()method example. This example shows you how to use getTime()method.This method Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").
Here is the code:-
/*
* @Program that Returns a Date object representing this Calendar's time value
* GetTime.java
* Author:-RoseIndia Team
* Date:-23-May-2008
*/
import java.util.*;
public class GetTime {
public static void main(String[] args) {
Calendar c= Calendar.getInstance();
System.out.println(" Current time is : "+c.getTime());
// Returns a Date object representing this Calendar's time value
Date d=c.getTime();
System.out.println(" Next time is : "+d);
}
} |
Output of the program:-
Current time is : Sat May 24 12:34:46 IST 2008
Next time is : Sat May 24 12:34:46 IST 2008 |
|