2

I have a date in a json string (returned from an ASP.NET rest service) that looks like this: "created": "/Date(1277931782420-0700)/"

Jackson is not able to parse this date. I can write my own date format and pass it in to mapper.getDeserializationConfig().setDateFormat(); but i was wondering if there is an easier/better way to do this...

Perception
  • 79,279
  • 19
  • 185
  • 195
Ben
  • 16,124
  • 22
  • 77
  • 122
  • 1
    What was the solution? I am not able to get a Java SimpleDateFormat to parse ASP JSON dates so I am wondering what date format implementation you used. – Nathan Dec 07 '11 at 02:32
  • we ended up switching to the standard GMT format on the server which jackson has no problem with... – Ben Dec 07 '11 at 08:43
  • In my case I have no control over the remote service I am integrating with. I have created my own basic implementation of java.text.DateFormat which handles ASP.Net JSON date strings. – Nathan Dec 07 '11 at 11:19

1 Answers1

2

I think defining date format is a reasonable way to do it. Alternatively you could define your own JsonDeserializer, register it, but it's not any simpler way (but may be more powerful if you need more complex parsing).

StaxMan
  • 113,358
  • 34
  • 211
  • 239
  • Can you guys give example of how that date format which parses "/Date(1277931782420-0700)/" would be defined in Java code for Jackson? – nikib3ro Feb 16 '13 at 04:23