Gson在centos出现的时间转换错误,在windows本机下测试没有问题

Caused by: java.text.ParseException: Unparseable date: "2012-11-29 15:15:06"

是系统的问题,我也没找到解决方案。

Gson converter = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").registerTypeAdapter(Date.class, new DateTypeAdapter()).create();

这也不行!!!

经过反复测试,用这个可以:

Gson converter = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();

圣杰是也
圣杰是也 
谢谢帮助. 在我的项目中试了下,解析出来的时间成了:"Mon Mar 17 14:57:43 格林尼治标准时间+0800 2014" 这种格式.显示的话很费劲啊..最后也懒得再尝试,采用split(" ")后,取第四个..唉.还是用fastjson吧..
 

猜你喜欢

转载自www.cnblogs.com/xzwzk/p/12310331.html
今日推荐