java.util.Calendar setLenient(boolean lenient)
Description :
This java tutorial shows how to use the setLenient(boolean lenient) method of Calendar class of java.util package. This method specifies whether or not date/time interpretation is to be lenient. The default value of isLenient is true.
Method Syntax :
public void setLenient(boolean lenient)
Parameter Input :
DataType | Parameter | Description |
---|---|---|
boolean | lenient | true if the lenient mode is to be turned on; false if it is to be turned off. |
Method Returns :
This method returns void.
Compatibility Version :
Requires Java 1.1 and up
Exception :
N/A
Java Code Example :
This java example source code demonstrates the use of setLenient(boolean lenient) method of Calendar class.
package com.javatutorialhq.java.examples; import java.util.Calendar; import java.util.TimeZone; /* * This example source code demonstrates the use of * setLenient(boolean lenient) method of Calendar class */ public class CalendarSetLenientExample { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); boolean result = cal.isLenient(); System.out.println("Is calendar lenient?"+result); cal.setLenient(false); result = cal.isLenient(); System.out.println("Is calendar lenient?"+result); } }
Sample Output :
Running the setLenient(boolean lenient) method example source code of Calendar class will give you the following output:
Is calendar lenient?true Is calendar lenient?false
Exception Scenario :
N/A
Similar Method :
- N/A
Suggested Reading List :
References :