Elad Benda2
Elad Benda2

Reputation: 15472

GSON JsonSyntaxException deserializing Java Date Object

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?

Upvotes: 1

Views: 4639

Answers (1)

Haspemulator
Haspemulator

Reputation: 11308

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.

Upvotes: 5

Related Questions