1

I am getting a JSON String and want to convert it to a typed Object.

however i get the following deserializtion error:

04-02 16:20:45.632: E/AndroidRuntime(30912): 
com.google.gson.JsonSyntaxException: 2014-03-25T19:10:07.1466Z

when trying to assign to this:

private Date endDateTime;

what would you suggest?

vzamanillo
  • 9,905
  • 1
  • 36
  • 56
Elad Benda2
  • 13,852
  • 29
  • 82
  • 157

1 Answers1

5

I might be a bit wrong with the date format, but take this as a guidance:

Gson gson = new GsonBuilder().setDateFormat("yyyy-MMM-dd HH:mm:ss.zzz").create();

And then use this instance to parse your input.

Haspemulator
  • 11,050
  • 9
  • 49
  • 76
  • how to use this is the date is just a field in my json. how to create the gson? – Elad Benda2 Apr 02 '14 at 20:46
  • The idea is that your instance of `Gson` class created in the way described in my answer will handle dates as you have specified in `setDateFormat` method call. You use it in the same way you do it currently, no difference whatsoever. – Haspemulator Apr 03 '14 at 07:56