Sunday 15 July 2018

How to use isLenient() and setLenient(boolean lenient) methods of Java.util.calendar class


Click here to watch on Youtube:
https://www.youtube.com/watch?v=EXcBl7tAUKU&list=UUhwKlOVR041tngjerWxVccw 

CalendarDemo.java

import java.util.Calendar;

public class CalendarDemo
{
    public static void main(String[] args)
    {
        Calendar cal = Calendar.getInstance();

        /*
         * Returns:true if the interpretation mode of this calendar is
         * lenient; false otherwise.
         */

        boolean isLenient = cal.isLenient();
        System.out.println("Calendar is lenient   = " + isLenient);

        /*
         * Parameters:
         *
         * lenient - true if the lenient mode is to be turned on;
         * false if it is to be turned off.
         */

        cal.setLenient(false);

        isLenient = cal.isLenient();
        System.out.println("Lenient after setting = " + isLenient);
    }
}

Output

Calendar is lenient   = true
Lenient after setting = false

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/CalendarDemo_isLenient.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/CalendarDemo_isLenient

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/fcab7bc6a80f12c850b8ccc28d71601c94666bbb/BasicJava_2018/CalendarDemo_isLenient/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a Comment