Hi!

Don't forget to setLenient false.

Hope snippet below is enough.

/Per

public final class LocalDateFormatValidator extends StringValidator {
    private static final long serialVersionUID = 1L;
    private final SimpleDateFormat dateFormat;

    public LocalDateFormatValidator(Locale locale) {
        this.dateFormat = (SimpleDateFormat) new
DateConverter().getDateFormat(locale);
        this.dateFormat.setLenient(false);
    }

(...)

    @Override
    protected void onValidate(IValidatable<String> validatable) {
        String dateString = validatable.getValue();
        try {
            dateFormat.parse(dateString);
        } catch (ParseException e) {
            error(validatable);
        }
    }
}

On Thu, Sep 24, 2009 at 10:10 AM, Charles Moulliard <[email protected]>wrote:

> I would like to know How I can validate the string date inputted by a
> user in a textfield of my form ?
>
> e.g : The SimpleDateformat to be used to create a java Date is : dd/MM/yyyy
> So I would like to check that the user has well introduced its date
> using this format
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to