Reputation: 3189
I'm trying to bind date in Grails App. In application.yml
I have databindings
for default JavaScript date formats:
grails:
databinding:
dateFormats:
- "yyyy-MM-dd'T'hh:mm:ss.S'Z'"
- "yyyy-MM-dd'T'HH:mm:ss'Z'"
In Groovy I'm creating object from params def entity = new Entity(params)
and everything binds OK, but...
The problem is that I have wrong time zone in my Grails app, i.e.:
Thu Oct 22 2015 00:00:00 GMT+0200 (CEST)
(this is string representation of Date
object)Next I'm sending it via $http
service, JSON payload looks like this: { date: "2015-10-21T22:00:00.000Z", another: "another:, property: "property" }
.
Date looks fine right now, Z
at the end means it is UTC so Thu Oct 22 2015 00:00:00 GMT+0200 (CEST)
- 2 hours => 2015-10-21T22:00:00.000Z
In Grails I'm doing def entity = new Entity(params)
and here is problem, entity.date
is equals to Wed Oct 21 22:00:00 CEST 2015
which means that Groovy/Grails parsed string 2015-10-21T22:00:00.000Z
as CEST time zone not UTC
So how can I force Grails to load date with proper format?
PS Both the web browser and computer is working with CEST time zone.
I'm using Grails 3.0
Upvotes: 2
Views: 917
Reputation: 3189
Proper datetime string is yyyy-MM-dd'T'HH:mm:ss.SSSX
.
In next versions this should be fixed and JavaScript datetime strings will be parsed via default parser.
More:
https://github.com/grails/grails-core/issues/9367 https://github.com/grails/grails-core/issues/9368
Upvotes: 2