Calendar class clear() method example
Calendar class clear()method example. This example shows you how to use clear()method.This method Sets all the calendar field values and the time value (millisecond offset from the Epoch) of this Calendar undefined.
Here is the code:-
/**
* @Program that Sets all the calendar field values and the time value
* (millisecond offset from the Epoch) of this Calendar undefined.
* clearcalender.java
* Author:-RoseIndia Team
* Date:-21-May-2008
*/
import java.util.*;
public class clearcalender {
public static void main(String[] args) {
//creating calender
Calendar cal1 = new GregorianCalendar(2009,07,14);
//displays the current date and time
System.out.println(cal1.getTime());
//Sets all the calendar field values and the time value (millisecond offset
//from the Epoch) of this Calendar undefined.
cal1.clear();
System.out.println(cal1.getTime());
}
} |
Output of the program:-
Fri Aug 14 00:00:00 IST 2009
Thu Jan 01 00:00:00 IST 1970 |
|