Question

I am using org.apache.commons.validator.routines.DateValidator to validate a date with a simple date pattern "dd/mm/yyyy"

Unfortunate part is that if I pass a date in format "2/2/1992" then it declares it as an invalid date and if I use format "d/m/yyyy" (In java SimpleDateFormat both these formats works for both cases), then date "02/02/1992" is invalid.

am I missing something. Cannot change the code to use Simple date formater due to some restriction.

Any ideas will be appreciated. Thanks.

Was it helpful?

Solution

You have to use non strict validation.. so do something like this.. DateValidator.isValid(date,format,'FALSE');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top