Java Calendar.setLenient(boolean lenient)

Syntax

Calendar.setLenient(boolean lenient) has the following syntax.

public void setLenient(boolean lenient)

Example

In the following code shows how to use Calendar.setLenient(boolean lenient) method.


import java.util.Calendar;
//from   ww  w.  j a va  2s .com
public class Main {

   public static void main(String[] args) {
      Calendar cal = Calendar.getInstance();

      // print current state of lenient
      boolean b = cal.isLenient();
      System.out.println("Calendar is lenient :" + b);

      // change lenient state
      cal.setLenient(false);

      System.out.println("Lenient after setting :" + cal.isLenient());

   }
}

The code above generates the following result.