Calendar setLenient() Method in Java with Examples Last Updated : 21 Feb, 2019 Comments Improve Suggest changes Like Article Like Report The setLenient(boolean leniency) method in Calendar class is used to specify whether the interpretation of the date and time is to be lenient or not. Syntax: public void setLenient(boolean leniency) Parameters: The method takes one parameter leniency of the boolean type that refers to the mode of the calendar. The boolean value true turns on the leniency mode and false turns off the leniency mode. Return Value: The method does not return any value. Below programs illustrate the working of setFirstDayOfWeek() Method of Calendar class: Example 1: Java // Java code to illustrate // setLenient() method import java.util.*; public class Calendar_Demo { public static void main(String args[]) { // Creating a calendar object Calendar calndr = Calendar.getInstance(); // Displaying the current // mood of leniency boolean value = calndr.isLenient(); System.out.println("Is the" + " Calendar lenient? " + value); // Changing the leniency calndr.setLenient(false); // Displaying the result System.out.println("The altered" + " Leniency: " + calndr.isLenient()); } } Output: Is the Calendar lenient? true The altered Leniency: false Example 2: Java // Java code to illustrate // isLenient() method import java.util.*; public class CalendarDemo { public static void main(String args[]) { // Creating a calendar object Calendar calndr = Calendar.getInstance(); // Displaying the calendar System.out.println("Current Calendar: " + calndr.getTime()); // Checking the leniency boolean leniency = calndr.isLenient(); calndr.setLenient(false); leniency = calndr.isLenient(); // Displaying the leniency System.out.println("Calendar is" + " lenient? " + leniency); // Checking the leniency calndr.setLenient(true); leniency = calndr.isLenient(); // Displaying the leniency System.out.println("Calendar is" + " lenient: " + leniency); } } Output: Current Calendar: Thu Feb 21 11:00:50 UTC 2019 Calendar is lenient? false Calendar is lenient: true Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#setLenient-boolean- Comment More infoAdvertise with us Next Article Calendar setLenient() Method in Java with Examples chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-Calendar +1 More Practice Tags : JavaMisc Similar Reads Calendar setTime() Method in Java with Examples The setTime(Date dt) method in Calendar class is used to set Calendars time represented by this Calendar's time value, with the given or passed date as a parameter. Syntax: public final void setTime(Date dt)) Parameters: The method takes one parameter dt of Date type and refers to the given date tha 2 min read Calendar set() Method in Java with Examples The set(int calndr_field, int new_val) method in Calendar class is used to set the calndr_field value to a new_val. The older field of this calendar get replaced by a new field. Syntax: public void set(int calndr_field, int new_val) Parameters: The method takes two parameters: calndr_field: This is 2 min read Calendar setTimeZone() Method in Java with Examples The setTimeZone(TimeZone time_zone) method in Calendar class takes a Time Zone value as a parameter and modifies or set the timezone represented by this Calendar. Syntax: public void setTimeZone(TimeZone time_zone) Parameters: The method takes one parameter time_zone of Date type and refers to the g 2 min read Calendar toString() Method in Java with Examples The toString() method in Calendar class is used to get the string representation of the Calendar object. This method in Calendar Class is just for debug process and not to be used as an operation. Syntax: public String toString() Parameters: The method does not take any parameters. Return Value: The 1 min read DateFormat setLenient() Method in Java with Examples The setLenient(boolean leniency) method in DateFormat class is used to specify whether the interpretation of the date and time of this DateFormat object is to be lenient or not. Syntax: public void setLenient(boolean leniency) Parameters: The method takes one parameter leniency of the boolean type t 2 min read Calendar setTimeInMillis() Method in Java with Examples The setTimeInMillis(long mill_sec) method in Calendar class is used to set Calendars time represented by this Calendar from the passed long value. Syntax: public void setTimeInMillis(long mill_sec) Parameters: The method takes one parameter mill_sec of long datat-type and refers to the given date th 2 min read Calendar add() Method in Java with Examples The add() method of Calendar class present inside is used to add or subtract from the given calendar field(int field), a specific amount of time(int amt), based on the calendar's rules. Syntax: public abstract void add(int field, int amt) Parameters: The method takes two parameters: The field of the 3 min read Calendar get() method in Java with Examples The get(int field_value) method of Calendar class is used to return the value of the given calendar field in the parameter. Syntax: public int get(int field) Parameters: The method takes one parameter field_value of integer type and refers to the calendar whose value is needed to be returned. Return 2 min read Calendar setFirstDayOfWeek() Method in Java with Examples The setFirstDayOfWeek(int day_val) method in Calendar class is used to set the first day of the week using the day_val in this Calendar. Syntax: public void set(int day_val) Parameters: The method takes one parameter day_val of integer type and refers to the first day of the week. Return Value: The 2 min read Date setTime() method in Java with Examples The setTime() method of Java Date class sets a date object. It sets date object to represent time milliseconds after January 1, 1970 00:00:00 GMT. Syntax: public void setTime(long time) Parameters: The function accepts a single parameter time which specifies the number of milliseconds. Return Value: 2 min read Like