Java Utility Library

Java Calendar - isLenient() Method



The java.util.Calendar.isLenient() method is used to tell whether the date/time interpretation is to be lenient.

Syntax

public boolean isLenient()

Parameters

No parameter is required.

Return Value

Returns true if the interpretation mode of this calendar is lenient; false otherwise.

Exception

NA

Example:

In the example below, the java.util.Calendar.isLenient() method is used to check whether the date/time interpretation is to be lenient.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a Calendar instance
    Calendar Cal = Calendar.getInstance();

    //creating a date object from calendar and printing it
    System.out.println("The Calendar is: " + Cal.getTime());

    //checks whether the date/time interpretation is lenient.
    System.out.println("Interpretation is lenient?: " + Cal.isLenient());    
  }
}

The output of the above code will be:

The Calendar is: Sun Sep 13 12:54:36 UTC 2020
Interpretation is lenient?: true

❮ Java.util - Calendar