{"action":"closed","issue":{"url":"https://api.github.com/repos/alibaba/fastjson/issues/447","repository_url":"https://api.github.com/repos/alibaba/fastjson","labels_url":"https://api.github.com/repos/alibaba/fastjson/issues/447/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/fastjson/issues/447/comments","events_url":"https://api.github.com/repos/alibaba/fastjson/issues/447/events","html_url":"https://github.com/alibaba/fastjson/issues/447","id":115478266,"number":447,"title":"关于SerializerFeature.UseISO8601DateFormat和Feature.AllowISO8601DateFormat的bug？？？！！","user":{"login":"GinKoSen","id":2233819,"avatar_url":"https://avatars.githubusercontent.com/u/2233819?v=3","gravatar_id":"","url":"https://api.github.com/users/GinKoSen","html_url":"https://github.com/GinKoSen","followers_url":"https://api.github.com/users/GinKoSen/followers","following_url":"https://api.github.com/users/GinKoSen/following{/other_user}","gists_url":"https://api.github.com/users/GinKoSen/gists{/gist_id}","starred_url":"https://api.github.com/users/GinKoSen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GinKoSen/subscriptions","organizations_url":"https://api.github.com/users/GinKoSen/orgs","repos_url":"https://api.github.com/users/GinKoSen/repos","events_url":"https://api.github.com/users/GinKoSen/events{/privacy}","received_events_url":"https://api.github.com/users/GinKoSen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-06T10:27:36Z","updated_at":"2016-04-13T14:06:28Z","closed_at":"2016-04-13T14:06:28Z","body":"##### 关于[SerializerFeature.UseISO8601DateFormat](#)和[Feature.AllowISO8601DateFormat](#)的bug？？？！！请官方确认，是否存在这样的问题。谢谢。\r\n\r\n#### **测试的案例**\r\n```java\r\npublic class TestMsk {\r\n\tpublic static void main(String[] args) {\r\n\t\tCalendar calendar = Calendar.getInstance();\r\n\t\tcalendar.set(Calendar.HOUR_OF_DAY, 0);\r\n\t\tcalendar.set(Calendar.MINUTE, 0);\r\n\t\tcalendar.set(Calendar.SECOND, 0);\r\n\t\tcalendar.set(Calendar.MILLISECOND, 0);\r\n\t\tFoo foo = new Foo();\r\n\t\tfoo.setCreateDate(calendar.getTime());\r\n\t\tString date = JSON.toJSONString(foo, SerializerFeature.UseISO8601DateFormat);\r\n\t\tSystem.err.println(date);\r\n\t\tFoo foo2 = JSON.parseObject(date, Foo.class, Feature.AllowISO8601DateFormat);\r\n\t\tSystem.err.println(JSON.toJSONString(foo2, SerializerFeature.WriteDateUseDateFormat));\r\n\t}\r\n\tpublic static class Foo {\r\n\t\tprivate String name;\r\n\t\tprivate Date createDate;\r\n\t\tpublic String getName() {\r\n\t\t\treturn name;\r\n\t\t}\r\n\t\tpublic void setName(String name) {\r\n\t\t\tthis.name = name;\r\n\t\t}\r\n\t\tpublic Date getCreateDate() {\r\n\t\t\treturn createDate;\r\n\t\t}\r\n\t\tpublic void setCreateDate(Date createDate) {\r\n\t\t\tthis.createDate = createDate;\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n```\r\n#### **运行结果**\r\n![run result](https://raw.githubusercontent.com/GinKoSen/ginko/master/images/sp1.png)\r\n\r\n通过对源码的阅读定位，得知对于[2015-10-10 00:00:00:00](#)这样的时间，\r\n如果使用了[SerializerFeature.UseISO8601DateFormat](#)会自动跳过值为0的一部分格式\r\n![codec](https://raw.githubusercontent.com/GinKoSen/ginko/master/images/sp2.png)\r\n\r\n然后对使用[Feature.AllowISO8601DateFormat](#)翻转，发现没有对时区前边 **[+/-]** 号特殊处理实现，只有对**(\")**\r\n![codec](https://raw.githubusercontent.com/GinKoSen/ginko/master/images/sp3.png)\r\n\r\n尝试把输出时间json中的+替换解析，依然报错。\r\n\r\n#### **所以个人猜测**\r\n##### 这个对[SerializerFeature.UseISO8601DateFormat](#)和[Feature.AllowISO8601DateFormat](#)是否存在**Bug**？造成对时间翻转不对称。\r\n\r\n##### 从github down下代码尝试修改，修改后运行测试案例，everything is ok ! (修改处如下)\r\n![codec](https://raw.githubusercontent.com/GinKoSen/ginko/master/images/sp4.png)\r\n"}}