Calendar isLenient() Method in Java with Examples
Last Updated :
19 Dec, 2022
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 the interpretation of this Calendar is lenient else False.
Below programs illustrate the working of isLenient() Method of Calendar class:
Example 1:
Java
import java.util.*;
public class CalendarDemo {
public static void main(String args[])
{
Calendar calndr = Calendar.getInstance();
System.out.println( "Current Calendar: "
+ calndr.getTime());
boolean leniency = calndr.isLenient();
System.out.println( "Calendar is"
+ " lenient: "
+ leniency);
}
}
|
Output
Current Calendar: Tue Nov 30 10:25:50 UTC 2021
Calendar is lenient: true
Example 2:
Java
import java.util.*;
public class CalendarDemo {
public static void main(String args[])
{
Calendar calndr = Calendar.getInstance();
System.out.println( "Current Calendar: "
+ calndr.getTime());
boolean leniency = calndr.isLenient();
calndr.setLenient( false );
leniency = calndr.isLenient();
System.out.println( "Calendar is"
+ " lenient: "
+ leniency);
}
}
|
Output
Current Calendar: Tue Nov 30 10:26:18 UTC 2021
Calendar is lenient: false
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#isLenient–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...