在webservice中java.util.Date作为参数传递时需要转化为XMLGregorianCalendar类型
?
?
public XMLGregorianCalendar convertToXMLGregorianCalendar(Date date) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); XMLGregorianCalendar gc = null; try { gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); } catch (Exception e) { e.printStackTrace(); } return gc; }
?
?
public Date convertToDate(XMLGregorianCalendar cal) throws Exception{ GregorianCalendar ca = cal.toGregorianCalendar(); return ca.getTime(); }
?