Java Calendar.isSet(int field)

Syntax

Calendar.isSet(int field) has the following syntax.

public final boolean isSet(int field)

Example

In the following code shows how to use Calendar.isSet(int field) method.


/*  w w w.j a v a  2  s.c o  m*/

import java.util.Calendar;

public class Main {

   public static void main(String[] args) {

      Calendar cal = Calendar.getInstance();

      boolean b = cal.isSet(Calendar.DAY_OF_MONTH);
      System.out.println("Day of month is set: " + b);

      // clear day of month
      cal.clear(Calendar.DAY_OF_MONTH);

      // determine if the given calendar field has a value set
      b = cal.isSet(Calendar.DAY_OF_MONTH);
      System.out.println("Day of month is set: " + b);
   }
}

The code above generates the following result.