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

Renderer makes date property null before db operation #64

Closed
daptordarattler opened this issue May 7, 2015 · 3 comments
Closed

Renderer makes date property null before db operation #64

daptordarattler opened this issue May 7, 2015 · 3 comments

Comments

@daptordarattler
Copy link

I have a date property on a domain model

Consignment{
       String  description
       Date dateDone

       Date dateCreated
       Date lastUpdated
}

Any time I update the dateDone from the client with javascript using code

consignment.dateDone = new Date().toISOString()

it is nulled in the resource code before even getting to the service operations
I have no Idea why. Its got me pulling out my hair all day.

@noamt
Copy link
Collaborator

noamt commented Jun 15, 2015

If you've got trouble debugging it, please post an example project or create a pull request with a test that reproduces it.

@budjb
Copy link
Contributor

budjb commented Mar 31, 2016

This issue was moved to budjb#23

@daptordarattler
Copy link
Author

I had the same problem for a long time and only recently solved it. The
grails data binding for date formats does not bind with the javascript
multiple date formats well so you have to add some date format patterns in
Config.groovy to fix this.

Here is the code I used:

//compatible with dates expressed as "2014-01-28T12:56:37+0100" as a wider range of date patterns
grails.databinding.dateFormats = ['yyyy-MM-dd HH:mm:ss.S',"yyyy-MM-dd HH:mm:ss.S z",
                          'yyyy-MM-dd HH:mm:ss.SSS',"yyyy-MM-dd HH:mm:ss.SSS z", 
                           "yyyy-MM-dd HH:mm:ss.SSS'Z'","yyyy-MM-ddHH:mm:ss.s'Z'","yyyy-MM-dd'T'HH:mm:ss'Z'",
                           "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'","yyyy-MM-dd'T'HH:mm:ss.S'Z'",
                           "EEE MMM dd yyyy HH:mm:ss 'GMT'Z (z)"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants