johan
johan

Reputation: 6666

Parse JSON date with GSON

How can I parse JSON dates with GSON? Keeps getting errors.

The date format in the JSON looks like this:

/Date(1313613992133+0200)\

Any advice would be appreciated!

Upvotes: 1

Views: 1563

Answers (2)

Siva Kumar
Siva Kumar

Reputation: 893

Try using

new Date(Long.parseLong("1313613992133")).toGMTString()

Upvotes: 1

peter.bartos
peter.bartos

Reputation: 12045

You can use:

    Date date = new Date(Integer.parseInt(jsonDateString.substr(6)));

Similar question answered here: How do I format a Microsoft JSON date?

Upvotes: 0

Related Questions