Announcement Announcement Module
No announcement yet.
re: date validation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • re: date validation

    Does anybody know how to get around the following error?

    Can't convert the date to string, because it is not known which parts of the
    date variable are in use. use ?date, ?time or ?datetime built-in, or ?string. or
    ?string (format) built-in with this date.

    I am using jsp for the input field:

    [@form.input path="testDate" /] has this line:{0} is an invalid date.

    Thanks for any tips on trapping the above error!

  • #2
    Sounds like you need to register a CustomDateEditor during the initial binding phase of your form-backing object. If your controllers are annotation-based it would look something like this:

    protected void initBinder(WebDataBinder binder) {
       SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
       binder.registerCustomEditor(Date.class, new CustomDateEditor(format, true));
    Refer to for clarification on the use of custom property editors. should point you in the right direction for CustomDateEditor usage.