Java DateFormat isLenient() Example

DateFormat class isLenient() method example. This example shows you how to use isLenient() method.


Syntax is : public boolean isLenient()
This method checks whether date/time parsing is to be lenient or not and returns boolean true or false.

Here is the code.
/**
 * @(#) IsLenientDateFormat.java
 * A class representing use of method isLenient() of DateFormat
class in java.text Package.
 * @Version  13-May-2008
 @author   Rose India Team
 */
import java.util.*;
import java.text.*;

class IsLenientDateFormat {

    public static void main(String[] args) {

        // Create new Date object that will be initialized to the current date.
        Date date = new Date();
        System.out.println("Date  by  Date  class    : " + date.toString());

        // Create new DateFormat object that will returns default date/time.
        DateFormat dateFormat = DateFormat.getInstance();

        // format method call.
        String stringDate = dateFormat.format(date);
        System.out.println("Date by DateFormat class : " + stringDate);

        // isLenient method call.
        boolean bool = dateFormat.isLenient();
        System.out.println("Date/time parsing is  lenient......" + bool);
    }
}

Output of the program.
 Date  by  Date  class    : Fri Jun 13 18:24:40 GMT+05:30 2008
Date by DateFormat class : 6/13/08 6:24 PM
Date/time parsing is  lenient......true

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US