Calendar.isLenient()

Date

Calendar.isLenient() To get status of Leninet of a Calendar.
Returns boolean: true or false , if the interpretation mode of this calendar is lenient then true otherwises false.
package my_proj;
 
import java.util.Calendar;
 
public class my_first {
public static void main(String[] args) {
Calendar my_cal = Calendar.getInstance();// created calendar
System.out.println(my_cal.isLenient()); // true
}
}
We can use setLenient() to change the interpretation mode .

package my_proj;
 
import java.util.Calendar;
 
public class my_first {
public static void main(String[] args) {
Calendar my_cal = Calendar.getInstance();// created calendar
System.out.println(my_cal.isLenient()); // true
my_cal.setLenient(false);
my_cal.set(2020,2,32);
System.out.println( my_cal.getTime());
}
}
Above code will generate exception. Change the code to my_cal.setLenient(true);
package my_proj;
 
import java.util.Calendar;
 
public class my_first {
public static void main(String[] args) {
Calendar my_cal = Calendar.getInstance();// created calendar
System.out.println(my_cal.isLenient()); // true
my_cal.setLenient(true);
my_cal.set(2020,2,32);
System.out.println( my_cal.getTime());
}
}
Output
true
Wed Apr 01 16:34:21 IST 2020
getLeastMaximum() getActualMaximum() Date & time tutorials


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer