Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending Date and time via Cloud Endpoints

I have an object with a java.util.Date attribute I am serializing with the AE Cloud Endpoints service. From the client, when I just send a date, everything works fine (ex: '2013-05-27'). When I try adding a time, it fails:

{ "error" : { "message" : "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Invalid date/time format: 2013-05-27T12:00 (through reference chain: com.foo.MyObject[\"date\"])" } }

The best resource for jackson's default date format I have been able to find is here: http://wiki.fasterxml.com/JacksonFAQDateHandling. I tried the full ISO-8601 "1970-01-01T00:00:00.000+0000" which failed as well. I also tried an UNIX timestamp which didn't fail on parsing, but set a date in the 1372's.

So two part question. One, what's the correct default format to use? And two, can we modify (do we have access to) the jackson config so we can set our own serialization format?

like image 953
jrmerz Avatar asked Dec 20 '22 05:12

jrmerz


1 Answers

Looks like it's close to the RFC 3339 standard, the fractional second appears to require 3 digits of precision, e.g.:

1985-04-12T23:20:50.520Z

This matches what's returned by the APIs Explorer, if you try it with your own API that includes a Date field.

With regards to handling the serialization yourself, you do not have access to the Jackson config, but you do have access to custom Endpoints serialization options (see @ApiSerializationProperty for instance).

like image 57
Dan Holevoet Avatar answered Jan 15 '23 20:01

Dan Holevoet