Sending date and time via cloud endpoints

I have an object with the java.util.Date attribute that I am serializing using the AE Cloud Endpoint Service. From the client, when I just send the date, everything works fine (for example: "2013-05-27"). When I try to add time, it fails:

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

The best resource for the Danish Jackson default format that I could find is here: http://wiki.fasterxml.com/JacksonFAQDateHandling . I tried completely ISO-8601 "1970-01-01T00: 00: 00.000 + 0000", which also failed. I also tried the UNIX timestamp, which did not fail to parse, but set the date to 1372.

So, a two-part question. One, what is the correct default format to use? And two, can we change (do we have access to) the jackson configuration so that we can set our own serialization format?

+4
source share
1 answer

It looks like it's close to the RFC 3339 standard, for a fractional second it takes 3 digits of accuracy, for example:

1985-04-12T23:20:50.520Z 

This is consistent with what was returned by the API if you try it using your own API, which includes the Date field.

As for the serialization processing itself, you do not have access to the Jackson configuration, but you do have access to customizable endpoint serialization parameters (see, for example, @ApiSerializationProperty ).

+11
source

Source: https://habr.com/ru/post/1483056/


All Articles