dungnn / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Date parse problem #420

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Consume a JSon collection object using java.util.Date
2. When set the GSonBuilder to use the datePattern "yyyy-MM-dd"
3. Get the unparsable Date

I think it's trying to create a Date using Integer instead of Long.
Too mainstream.

java.text.ParseException: Unparseable date: "1323434500000"

Original issue reported on code.google.com by santana....@gmail.com on 15 Mar 2012 at 2:15

GoogleCodeExporter commented 9 years ago
Could you provide a complete test case? It looks like your parsing a date 
formatted as a long rather than as a string.

Original comment by limpbizkit on 18 Mar 2012 at 5:57

GoogleCodeExporter commented 9 years ago
I found the problem.

I was receiving the JSON sometimes with a string date and sometimes with long, 
so I created a TypeAdapter and the problem is resolved.

Thanks.

Original comment by santana....@gmail.com on 18 Mar 2012 at 7:21