67,512
社区成员
发帖
与我相关
我的任务
分享
List list = new ArrayList();
list.add(new Student("zhou", 26,Date.valueOf("1986-03-05")));
list.add(new Student("zheng", 23,Date.valueOf("1999-04-21")));
list.add(new Student("yu", 25,Date.valueOf("2000-03-05")));
JSONArray array1 = JSONArray.fromObject(list);
for(Object obj:array1){
System.out.println(obj);
}
Exception in thread "main" net.sf.json.JSONException: java.lang.reflect.InvocationTargetException
at net.sf.json.JSONObject._fromBean(JSONObject.java:953)
at net.sf.json.JSONObject.fromObject(JSONObject.java:192)
at net.sf.json.JSONObject._processValue(JSONObject.java:2774)
at net.sf.json.JSONObject._setInternal(JSONObject.java:2798)
at net.sf.json.JSONObject.setValue(JSONObject.java:1507)
at net.sf.json.JSONObject._fromBean(JSONObject.java:940)
at net.sf.json.JSONObject.fromObject(JSONObject.java:192)
at net.sf.json.JSONArray._processValue(JSONArray.java:2557)
at net.sf.json.JSONArray.processValue(JSONArray.java:2588)
at net.sf.json.JSONArray.addValue(JSONArray.java:2575)
at net.sf.json.JSONArray._fromCollection(JSONArray.java:1082)
at net.sf.json.JSONArray.fromObject(JSONArray.java:145)
at net.sf.json.JSONArray.fromObject(JSONArray.java:127)
at test01.test2.main(test2.java:26)
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:928)
... 13 more
Caused by: java.lang.IllegalArgumentException
at java.sql.Date.getHours(Date.java:143)
... 23 more