webservice时间类型XMLGregorianCalendar和Date的转换

//ISO日期转换为UTC日期
public XMLGregorianCalendar xmlToDate(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;
} //UTC日期转换为ISO日期
public Date DateToXML(XMLGregorianCalendar gc){
GregorianCalendar ca = gc.toGregorianCalendar();
return ca.getTime();
}
上一篇:JavaScript常用设计模式


下一篇:HTML-常用标签与表格标签