Calendar.clear() has the following syntax.
public final void clear()
In the following code shows how to use Calendar.clear() method.
//from ww w. j a v a2 s . c om 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.