Javatpoint Logo
Javatpoint Logo

Java Calendar clear() Method

The java.util.Calendar.clear() method sets the given calendar field value and the time value of this Calendar undefined. A Calendar implementation class may use default field values for date and time calculations.

Syntax

Parameter

Field - calendar field to set as undefined.

Returns

This method does not return any value.

Throws

NA

Example 1

Test it Now

Output:

Current Calendar Date: Mon Jul 30 06:35:54 PDT 2018
The calendar shows : Thu Jul 30 06:35:54 PDT 1970

Example 2

Test it Now

Output:

Current Calendar Date: Mon Jul 30 06:39:17 PDT 2018
The calendar shows : Tue Jan 30 06:39:17 PST 2018

Example 3

Test it Now

Output:

Current Calendar Date: Mon Jul 30 06:45:15 PDT 2018
The calendar shows : Mon Jul 30 06:45:15 PDT 2018
The calendar shows : Mon Jul 30 06:00:00 PDT 2018 

Example 4

Test it Now

Output:

Current Calendar Date: Mon Jul 30 06:48:47 PDT 2018
The calendar shows : Mon Jul 30 06:00:00 PDT 2018



Help Others, Please Share

facebook twitter pinterest