Calendar isSet() Method in Java with Examples Last Updated : 18 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The isSet(int calndr_field) method in Calendar class is used to check whether the given calendar field has a value set or not. All the Cases for which the values have been set by the calculations of the internal field are triggered by a get method call. Syntax: public final boolean isSet(int calndr_field) Parameters: The method takes one parameter calndr_field that refers to the calendar field which is to be operated upon.Return Value: The method either returns True if the value of the calendar field is set else it returns False. Below programs illustrate the working of isSet() Method of Calendar class: Example 1: Java // Java code to illustrate // isSet() method import java.util.*; public class CalendarDemo { public static void main(String args[]) { // Creating a calendar object Calendar calndr = Calendar.getInstance(); // Displaying the calendar object System.out.println("The Year is: " + calndr.get(Calendar.YEAR)); // Querying for the value if set or not boolean val = calndr.isSet(Calendar.YEAR); System.out.println("Is the" + " Value set? " + val); // Clearing the instance calndr.clear(Calendar.YEAR); // Performing isSet() operation val = calndr.isSet(Calendar.YEAR); System.out.println("Is the" + " Value set? " + val); } } Output: The Year is: 2019 Is the Value set? true Is the Value set? false Example 2: Java // Java code to illustrate // isSet() method import java.util.*; public class CalendarDemo { public static void main(String args[]) { // Creating a calendar object Calendar calndr = Calendar.getInstance(); // Displaying the calendar object System.out.println("Todays Day is: " + calndr.get( Calendar.DAY_OF_MONTH)); // Querying for the value if set or not boolean val = calndr.isSet(Calendar.DAY_OF_MONTH); System.out.println("Is the" + " Value set? " + val); // Clearing the instance calndr.clear(Calendar.DAY_OF_MONTH); // Performing isSet() operation val = calndr.isSet(Calendar.DAY_OF_MONTH); System.out.println("Is the" + " Value set? " + val); } } Output: Todays Day is: 21 Is the Value set? true Is the Value set? false Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#isSet-int- Comment More infoAdvertise with us Next Article Calendar isLenient() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-Calendar +1 More Practice Tags : JavaMisc Similar Reads Calendar isLenient() Method in Java with Examples The isLenient() method in Calendar class is used to know and understand whether the date and time interpretation of this Calendar is to be considered lenient or not.Syntax: public boolean isLenient() Parameters: The method does not take any parameters.Return Value: The method either returns True if 2 min read Calendar internalGet() Method in Java with Examples The internalGet(int calndr_field) method in Calendar class is used to return the value of the given calendar field as a parameter. Note: The operation does not involve any normalization or validation. Syntax: protected final int internalGet(int calndr_field) Parameters: The method takes one paramete 2 min read Calendar add() Method in Java with Examples The add() method of Calendar class present inside is used to add or subtract from the given calendar field(int field), a specific amount of time(int amt), based on the calendar's rules. Syntax: public abstract void add(int field, int amt) Parameters: The method takes two parameters: The field of the 3 min read Calendar get() method in Java with Examples The get(int field_value) method of Calendar class is used to return the value of the given calendar field in the parameter. Syntax: public int get(int field) Parameters: The method takes one parameter field_value of integer type and refers to the calendar whose value is needed to be returned. Return 2 min read Calendar set() Method in Java with Examples The set(int calndr_field, int new_val) method in Calendar class is used to set the calndr_field value to a new_val. The older field of this calendar get replaced by a new field. Syntax: public void set(int calndr_field, int new_val) Parameters: The method takes two parameters: calndr_field: This is 2 min read Calendar clear() Method in Java with Examples The clear() method in Calendar class is used to set all the calendar field values and the time value of this Calendar undefined. Note: Implementation of calendar class may use default field values for date and time calculations. Syntax: public final void clear() Parameters: The method does not take 2 min read Like