Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.validator
Class DateValidator

    java.lang.Object
      |
      +--org.apache.commons.validator.DateValidator

public class DateValidator
extends java.lang.Object

Perform date validations.

This class is a Singleton; you can retrieve the instance via the getInstance() method.

Since:
  Validator 1.1
Version:
  $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $

Constructor Summary
`protected` | `DateValidator()` Protected constructor for subclasses to use.

Method Summary
`static DateValidator` | `getInstance()` Returns the Singleton instance of this validator.
`boolean` | `isValid(java.lang.String value, java.util.Locale locale)` Checks if the field is a valid date.
`boolean` | `isValid(java.lang.String value, java.lang.String datePattern, boolean strict)` Checks if the field is a valid date.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DateValidator

    protected DateValidator()

  Protected constructor for subclasses to use.

Method Detail

### getInstance

    public static DateValidator getInstance()

  Returns the Singleton instance of this validator.
  Returns:
    A singleton instance of the DateValidator.

### isValid

    public boolean isValid(java.lang.String value,
                           java.lang.String datePattern,
                           boolean strict)

  Checks if the field is a valid date. The pattern is used with `java.text.SimpleDateFormat`. If strict is true, then the length will be checked so '2/12/1999' will not pass validation with the format 'MM/dd/yyyy' because the month isn't two digits. The setLenient method is set to `false` for all.

  Parameters:
    `value` - The value validation is being performed on.
    `datePattern` - The pattern passed to `SimpleDateFormat`.
    `strict` - Whether or not to have an exact match of the datePattern.
  Returns:
    true if the date is valid.

### isValid

    public boolean isValid(java.lang.String value,
                           java.util.Locale locale)

  Checks if the field is a valid date. The `Locale` is used with `java.text.DateFormat`. The setLenient method is set to `false` for all.

  Parameters:
    `value` - The value validation is being performed on.
    `locale` - The locale to use for the date format, defaults to the default system default if null.
  Returns:
    true if the date is valid.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2006 The Apache Software Foundation. All Rights Reserved.