Skip to content

Grails @BindingFormat does not throw any error if date is supplied in some other format. #9667

@ejaz-ahmed

Description

@ejaz-ahmed

The solution to this problem is simpleDateFormat.setLenient(false). Here is grails console output of @jeffbrown 's investigation on slack channel.

groovy:000> fmt = new java.text.SimpleDateFormat('dd/MM/yyyy')
===> java.text.SimpleDateFormat@d936eac0
groovy:000> fmt.parse('1969/11/15')
===> Sat Mar 22 00:00:00 CST 21
groovy:000> fmt.lenient = false
===> false
groovy:000> fmt.parse('1969/11/15')
ERROR java.text.ParseException:
Unparseable date: "1969/11/15"
        at java_text_DateFormat$parse.call (Unknown Source)

Here is related slack discussion. https://grails.slack.com/archives/questions/p1455114212002156

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions