Java Calendar isSet() Method

The isSet() method of java.util.Calendar class is a final method which returns the Boolean value. This method checks whether the passed parameter value is set or not. If it is not set, it returns false otherwise true

Syntax

Parameter

field - the calendar field.

Returns

Returns a Boolean value.

Throws

Does not throw Exception.

Example 1

Output:

Today Mon Aug 13 22:21:16 PDT 2018
Year is set: true
Year is set: false

Example 2

Output:

Today Mon Aug 13 22:29:19 PDT 2018
Year is set: true
Month is set: true
Day of week is set: true
After clearing calendar
Year is set: false
Month is set: false
Day of week is set: false