Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 [SPR-8669] #13311

Closed
spring-projects-issues opened this issue Sep 5, 2011 · 3 comments
Labels
in: web status: bulk-closed

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Sep 5, 2011

Angel opened SPR-8669 and commented

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));
    }

Affects: 3.1 M2

4 votes, 2 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 14, 2012

Malcolm Warren commented

Absolutely.

To avoid the empty String with dates problem I've ended up having register a separate custom editor for every date and time field in my entity.
This is clearly a maintenance nightmare.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 12, 2013

Ben Pearson commented

We need to be able to set the leniency on the format.

@spring-projects-issues spring-projects-issues added status: waiting-for-triage type: enhancement in: web and removed type: enhancement labels Jan 11, 2019
@rstoyanchev rstoyanchev added status: bulk-closed and removed status: waiting-for-triage labels Jan 11, 2019
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web status: bulk-closed
Projects
None yet
Development

No branches or pull requests

2 participants