Convert JAXB XMLGregorianCalendar to java.sql.Date

P

puneet.maini

Hello,

Do you know of a way to convert
javax.xml.datatype.XMLGregorianCalendar
--- to ---
java.sql.Date.


I'm parsing (unmarshalling) an xml doc using JAXB api, and I need to
save the date i'm getting from xml into the database.

Does anyone know of a possible way of doing this.

Thanks in advance.
 
Joined
Apr 16, 2009
Messages
1
Reaction score
0
I know you must have been set with the issue by now. Just posting it here for anyone having the same question:

Try this:

XMLGregorianCalendar xcal = <assume this is initialized>;
java.util.Date dt = xcal.toGregorianCalendar().getTime();

To get a SQL version Date:
java.sql.Date sqlDt = new java.sql.Date(dt.getTime());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top