Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8669

Annotation @DateTimeFormat needs a parameter to specify if you want to acept null or blank values to avoid exceptions when a date field is not mandatory

    XMLWordPrintable

    Details

    • Last commented by a User:
      true

      Description

      This enhancement would make the following addition to my controller completely unnecessary:

          @InitBinder
          public void initBinder(WebDataBinder binder) {
              SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
              dateFormat.setLenient(false);
      
              // true passed to CustomDateEditor constructor means convert empty String to null
              binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
          }
      

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            pakin Angel
            Last updater:
            Spring Issues Spring Issues
            Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              3 years, 24 weeks, 1 day ago