Brandon Wagner
Brandon Wagner

Reputation: 893

Dates in Grails 2.2 to 2.3

I just upgraded a Grails application from 2.2 to 2.3 and ran into some errors in my code regarding dates. As soon as I upgraded, my dates were failing validation. The dates are in the format "MM/DD/yyyy HH:mm" . Grails 2.2 were handling them fine, but 2.3 cannot bind to a Date object. I've done a work around by parsing the text into a date object, but it's not as clean as I would like.

Upvotes: 3

Views: 331

Answers (2)

Dónal
Dónal

Reputation: 187499

The databinding was changed significantly in 2.3, and this is almost certainly the cause of your problem. If you want to use the old databinding behaviour in Grails 2.3 add the following to Config.groovy

grails.databinding.useSpringBinder = true

Upvotes: 1

grantmcconnaughey
grantmcconnaughey

Reputation: 10689

Add the date format to grails.databinding.dateFormats in Config.groovy.

grails.databinding.dateFormats = ['MM/DD/yyyy HH:mm']

The data binding documentation goes into more detail.

Upvotes: 3

Related Questions