[json-lib-user] error serializing java.sql.Date
Brought to you by:
aalmiray
From: 刘. <liu...@gm...> - 2008-02-14 01:29:42
|
json-lib version 2.2.1 code: java.sql.Date d = new java.sql.Date(System.currentTimeMillis()); > HashMap m = new HashMap(); > m.put("date", d); > JSONObject json = JSONObject.fromObject(m); output: Exception in thread "main" net.sf.json.JSONException: > java.lang.reflect.InvocationTargetException > at net.sf.json.JSONObject._fromBean(JSONObject.java:949) > at net.sf.json.JSONObject.fromObject(JSONObject.java:189) > at net.sf.json.JSONObject._processValue(JSONObject.java:2753) > at net.sf.json.JSONObject._setInternal(JSONObject.java:2777) > at net.sf.json.JSONObject.setValue(JSONObject.java:1503) > at net.sf.json.JSONObject._fromMap(JSONObject.java:1280) > at net.sf.json.JSONObject.fromObject(JSONObject.java:180) > at net.sf.json.JSONObject.fromObject(JSONObject.java:151) > at demo.JsonDate.main(JsonDate.java:24) > Caused by: java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke( > NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod( > PropertyUtilsBean.java:1773) > at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty( > PropertyUtilsBean.java:1132) > at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty( > PropertyUtilsBean.java:686) > at org.apache.commons.beanutils.PropertyUtilsBean.getProperty( > PropertyUtilsBean.java:715) > at org.apache.commons.beanutils.PropertyUtils.getProperty( > PropertyUtils.java:290) > at net.sf.json.JSONObject._fromBean(JSONObject.java:924) > ... 8 more > Caused by: java.lang.IllegalArgumentException > at java.sql.Date.getHours(Date.java:143) > ... 18 more > |