{"action":"closed","issue":{"url":"https://api.github.com/repos/alibaba/fastjson/issues/476","repository_url":"https://api.github.com/repos/alibaba/fastjson","labels_url":"https://api.github.com/repos/alibaba/fastjson/issues/476/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/fastjson/issues/476/comments","events_url":"https://api.github.com/repos/alibaba/fastjson/issues/476/events","html_url":"https://github.com/alibaba/fastjson/issues/476","id":124624194,"number":476,"title":"使用SerializeFilter的JSON.toJSONString的时候会强制设置SerializerFeature.WriteDateUseDateFormat，导致Date类型转换了yyyy-MM-dd HH:mm:ss","user":{"login":"myoss","id":6986459,"avatar_url":"https://avatars.githubusercontent.com/u/6986459?v=3","gravatar_id":"","url":"https://api.github.com/users/myoss","html_url":"https://github.com/myoss","followers_url":"https://api.github.com/users/myoss/followers","following_url":"https://api.github.com/users/myoss/following{/other_user}","gists_url":"https://api.github.com/users/myoss/gists{/gist_id}","starred_url":"https://api.github.com/users/myoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myoss/subscriptions","organizations_url":"https://api.github.com/users/myoss/orgs","repos_url":"https://api.github.com/users/myoss/repos","events_url":"https://api.github.com/users/myoss/events{/privacy}","received_events_url":"https://api.github.com/users/myoss/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/alibaba/fastjson/milestones/5","html_url":"https://github.com/alibaba/fastjson/milestones/1.2.9","labels_url":"https://api.github.com/repos/alibaba/fastjson/milestones/5/labels","id":1691601,"number":5,"title":"1.2.9","description":"","creator":{"login":"wenshao","id":1166785,"avatar_url":"https://avatars.githubusercontent.com/u/1166785?v=3","gravatar_id":"","url":"https://api.github.com/users/wenshao","html_url":"https://github.com/wenshao","followers_url":"https://api.github.com/users/wenshao/followers","following_url":"https://api.github.com/users/wenshao/following{/other_user}","gists_url":"https://api.github.com/users/wenshao/gists{/gist_id}","starred_url":"https://api.github.com/users/wenshao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wenshao/subscriptions","organizations_url":"https://api.github.com/users/wenshao/orgs","repos_url":"https://api.github.com/users/wenshao/repos","events_url":"https://api.github.com/users/wenshao/events{/privacy}","received_events_url":"https://api.github.com/users/wenshao/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":21,"state":"open","created_at":"2016-04-08T05:11:52Z","updated_at":"2016-04-13T08:53:47Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-01-03T02:36:19Z","updated_at":"2016-04-13T08:53:47Z","closed_at":"2016-04-13T08:53:47Z","body":"serializer.config(SerializerFeature.WriteDateUseDateFormat, true);\r\n\r\n为什么要强制设置这个？如果我features设置了false都不会起作用，我正常的使用JSON.toJSONString(object)输出的Date类型的字段是long类型的数字，而用了下面这2个方法，Date类型都转换成了这种格式\"2016-01-02 17:46:41\"，我看源码，发现了这个强制性的设置\r\n\r\n\r\n\r\n方法1：\r\npublic static String toJSONString(Object object, SerializeFilter[] filters, SerializerFeature... features) {\r\n        SerializeWriter out = new SerializeWriter();\r\n\r\n        try {\r\n            JSONSerializer serializer = new JSONSerializer(out);\r\n            for (com.alibaba.fastjson.serializer.SerializerFeature feature : features) {\r\n                serializer.config(feature, true);\r\n            }\r\n\r\n            serializer.config(SerializerFeature.WriteDateUseDateFormat, true);\r\n\r\n            setFilter(serializer, filters);\r\n\r\n            serializer.write(object);\r\n\r\n            return out.toString();\r\n        } finally {\r\n            out.close();\r\n        }\r\n    }\r\n\r\n方法2：\r\n    public static String toJSONString(Object object, SerializeFilter filter, SerializerFeature... features) {\r\n        SerializeWriter out = new SerializeWriter();\r\n\r\n        try {\r\n            JSONSerializer serializer = new JSONSerializer(out);\r\n            for (com.alibaba.fastjson.serializer.SerializerFeature feature : features) {\r\n                serializer.config(feature, true);\r\n            }\r\n\r\n            serializer.config(SerializerFeature.WriteDateUseDateFormat, true);\r\n\r\n            setFilter(serializer, filter);\r\n\r\n            serializer.write(object);\r\n\r\n            return out.toString();\r\n        } finally {\r\n            out.close();\r\n        }\r\n    }"}}