XMLGregorianCalendar和 java.sql.Timestamp相互转化

从XMLGregorianCalendar转换成Timestamp
Timestamp timestamp = new Timestamp(var2.getXMLGregorianCalendar().toGregorianCalendar().getTimeInMillis());


从Timestamp转换成XMLGregorianCalendar
Timestamp ts = new Timestamp(new Date().getTime());
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(new Date(ts.getTime()));
XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);

你可能感兴趣的:(java)