Java Calendar.clear()
Syntax
Calendar.clear() has the following syntax.
public final void clear()
Example
In the following code shows how to use Calendar.clear() method.
/* w ww . j a va 2 s. com*/
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
// create calendar object
Calendar cal = Calendar.getInstance();
// displays the current date and time
System.out.println("Current Calendar Date: " + cal.getTime());
// use clear method to set all field values and time value as undefined.
cal.clear();
// print the result
System.out.println("The calendar shows : " + cal.getTime());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »