@@ -0,0 +1,2228 @@
+package com.alibaba.json.bvt.bug;%0A%0Aimport com.alibaba.fastjson.JSON;%0Aimport com.alibaba.fastjson.JSONArray;%0Aimport junit.framework.TestCase;%0A%0Aimport javax.xml.datatype.DatatypeFactory;%0Aimport javax.xml.datatype.XMLGregorianCalendar;%0Aimport java.util.ArrayList;%0Aimport java.util.Date;%0Aimport java.util.GregorianCalendar;%0Aimport java.util.List;%0A%0A/**%0A * Created by wenshao on 11/03/2017.%0A */%0Apublic class Issue1023 extends TestCase %7B%0A    public void test_for_issue() throws Exception %7B%0A        Date now = new Date();%0A%0A        GregorianCalendar gregorianCalendar = (GregorianCalendar) GregorianCalendar.getInstance();%0A        gregorianCalendar.setTime(now);%0A%0A        XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);%0A%0A        String jsonString = JSON.toJSONString(calendar);%0A        // success%0A        calendar = JSON.parseObject(jsonString, XMLGregorianCalendar.class);%0A%0A        Object toJSON1 = JSON.toJSON(calendar); // debug%E7%9C%8B%E5%88%B0%E6%98%AF Long %E7%B1%BB%E5%9E%8B%0A        // %E6%89%80%E4%BB%A5%E8%BF%99%E9%87%8C%E4%BC%9A%E6%8A%A5%E9%94%99%EF%BC%9A%0A        // error: java.lang.ClassCastException: java.lang.Long cannot be cast to com.alibaba.fastjson.JSONObject%0A        //JSONObject jsonObject = (JSONObject) JSON.toJSON(calendar);%0A        // %E6%89%80%E4%BB%A5 %E8%BF%99%E9%87%8C%E8%82%AF%E5%AE%9A%E4%BC%9A%E6%8A%A5%E9%94%99%EF%BC%8C %E5%9B%A0%E4%B8%BA jsonObject %E4%B8%8D%E6%98%AFJSONObject%E7%B1%BB%E5%9E%8B%0A        //calendar = jsonObject.toJavaObject(XMLGregorianCalendar.class);%0A%0A        List%3CXMLGregorianCalendar%3E calendarList = new ArrayList%3CXMLGregorianCalendar%3E();%0A        calendarList.add(calendar);%0A        calendarList.add(calendar);%0A        calendarList.add(calendar);%0A%0A        Object toJSON2 = JSON.toJSON(calendarList); // debug %E7%9C%8B%E5%88%B0%E6%98%AF JSONArray %E7%B1%BB%E5%9E%8B%0A%0A        // success%EF%BC%9A %E9%80%9A%E8%BF%87 JSONArray.parseArray %E6%96%B9%E6%B3%95%E5%8F%AF%E4%BB%A5%E6%AD%A3%E7%A1%AE%E8%BD%AC%E6%8D%A2%0A        JSONArray jsonArray = (JSONArray) JSON.toJSON(calendarList);%0A        jsonString = jsonArray.toJSONString();%0A        List%3CXMLGregorianCalendar%3E calendarList1 = JSONArray.parseArray(jsonString, XMLGregorianCalendar.class);%0A%0A        // %E9%80%9A%E8%BF%87 jsonArray.toJavaList %E6%97%A0%E6%B3%95%E8%BD%AC%E6%8D%A2%0A        // error: com.alibaba.fastjson.JSONException: can not cast to : javax.xml.datatype.XMLGregorianCalendar%0A        List%3CXMLGregorianCalendar%3E calendarList2 = jsonArray.toJavaList(XMLGregorianCalendar.class);%0A        assertNotNull(calendarList2);%0A        assertEquals(3, calendarList2.size());%0A    %7D%0A%7D%0A

add testcase for issue #1023