Calendar.setLenient()

Date

Calendar.setLenient(true / false ) To set status of Leninet of a Calendar.
package my_proj;
 
import java.util.Calendar;
 
public class my_first {
public static void main(String[] args) {
Calendar my_cal = Calendar.getInstance();// created calendar
my_cal.setLenient(true); 
}
}
We can use getLenient() to collect 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
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
my_cal.setLenient(true); 
my_cal.set(2020,2,32);
System.out.println( my_cal.isLenient()); //true
System.out.println( my_cal.getTime());
}
}
Output
true
Wed Apr 01 16:49:44 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-2022 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer