关于Gson解析时间时的问题
高洛峰
高洛峰 2016-11-10 17:00:24
0
2
1807

关于Gson解析时间时的问题

com.google.gson.JsonSyntaxException: 1461689198000
04-27 00:46:51.159 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:74)
04-27 00:46:51.159 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:59)
04-27 00:46:51.159 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:41)
04-27 00:46:51.159 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:879)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:844)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.Gson.fromJson(Gson.java:793)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.yurikami.lib.net.parser.impl.ModelParser.parse(ModelParser.java:48)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.yurikami.lib.net.UICallBack.onResponse(UICallBack.java:54)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at java.lang.Thread.run(Thread.java:818)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err: Caused by: java.text.ParseException: Failed to parse date ["1461689198000']: Invalid time zone indicator '9' (at offset 0)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:274)
04-27 00:46:51.160 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:72)
04-27 00:46:51.166 17190-20868/link.ebbinghaus.planning W/System.err:     ... 16 more
04-27 00:46:51.166 17190-20868/link.ebbinghaus.planning W/System.err: Caused by: java.lang.IndexOutOfBoundsException: Invalid time zone indicator '9'
04-27 00:46:51.166 17190-20868/link.ebbinghaus.planning W/System.err:     at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:245)
04-27 00:46:51.166 17190-20868/link.ebbinghaus.planning W/System.err:     ... 17 more


高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(2)
三叔

gson默认可能无法识别这种格式,可能需要你写个转换适配器才行

学霸

很好的解决了我的问题,一开始以为是 gson.setDateFormat(DateFormat.LONG) .

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!