commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <>
Subject [jira] Commented: (VALIDATOR-221) DateValidator considers "02/29" with format "MM/dd" invalid
Date Mon, 29 Jan 2007 22:47:49 GMT


Niall Pemberton commented on VALIDATOR-221:

This is a valid point but DateValidator is built on the premise of validating dates using
java's DateFormat's parse method. Since as you point out this is a defect in the DateFormat
implementation(s) then I don't really see a solution to this issue for the implementations
validator provides.

If you can put forward a solution, I'd be happy to consider it - if not though I'll probably
close this as WONT FIX.

> DateValidator considers "02/29" with format "MM/dd" invalid
> -----------------------------------------------------------
>                 Key: VALIDATOR-221
>                 URL:
>             Project: Commons Validator
>          Issue Type: Bug
>    Affects Versions: 1.3.1 Release
>         Environment: Windows XP, Java 1.5.0_04
>            Reporter: Carsten Drossel
>            Priority: Minor
> When the date pattern contains only day and month the isValid(..)-method of DateValidator
returns false for the value Feb. 29th.
> Here is a JUnit test that fails:
> public void testFebruary29th() throws Exception {
>   assertTrue( DateValidator.getInstance().isValid( "02/29", "MM/dd", true ) );
> }
> The DateValidator uses the parse(..)-method of SimpleDateFormat for the validation. This
method appears to complete any date using 01/01/1970 00:00. Since 1970 was not a leap year
a ParseException is thrown for the input "02/29" with the format "MM/dd" because 02/29/1970
is not a valid date.
> But IMHO "02/29" should be valid. An example where it makes sense is a search for persons
with a certain birthday. 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message