PreparedStatement pstmt = con.prepareStatement("SELECT getDate()");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
java.sql.Date d = rs.getDate(4);
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(d);
XMLGregorianCalendar gc =
DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
}
Here's an example of going the other direction; getting a java.sql.Data from an
XMLGregorianCalendar.
XMLGregorianCalendar gc /* = something */;
GregorianCalendar c = gc.toGregorianCalendar();
java.util.Date d = c.getTime();
java.sql.Data sqlDate = new java.sql.Date(d.getTime());
1 comment:
Well written article.
Post a Comment