/**
* Date转化为XMLGregorianCalendar
* @param date
* @return
*/
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;
}
/**
* XMLGregorianCalendar 转Date
* @param cal
* @return
*/
public Date convertToDate(XMLGregorianCalendar cal){
GregorianCalendar ca = null;
if(cal!=null && cal.toGregorianCalendar()!=null){
ca = cal.toGregorianCalendar();
return ca.getTime();
}
return null;
}
Date 和 XMLGregorianCalendar 转换
最新推荐文章于 2023-11-08 15:01:45 发布