简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM