- import java.util.Date;
- import java.util.HashMap;
- import java.util.Map;
-
- import net.sf.json.JSONObject;
- import net.sf.json.JsonConfig;
-
- public class Test {
- public static void main(String[] args) {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("time", new Date());
- map.put("name", "yy");
- map.put("age", 20);
- JsonConfig config = new JsonConfig();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("G yyyy-MM-dd hh:mm:ss.SS zzz ZZZ w DDD FF EE"));
- JSONObject Obj = JSONObject.fromObject(map, config);
-
- System.out.println(Obj);
- }
- }
原文出自:http://blog.csdn.net/heardy/article/details/6760722