The moose likes XML and Related Technologies and the fly likes convert XMLGregorianCalender into java.util.date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "convert XMLGregorianCalender into java.util.date" Watch "convert XMLGregorianCalender into java.util.date" New topic

convert XMLGregorianCalender into java.util.date

bhargavi kakarala
Ranch Hand

Joined: Jan 03, 2002
Posts: 82
Hi all,

could anyone of you help me converting XMLGregorianCalendar timestamp into util DateTime and date into Date

here is the sample I have
public XMLGregorianCalendar getEntryDateTime() {
return entryDateTime;

Thanks in advance.

SCJP2,SCWD,SCBCD,IBM Certified SOA Associate,IBM Certified Architectural Design of SOA Solutions
bhargavi kakarala
Ranch Hand

Joined: Jan 03, 2002
Posts: 82
its ok.

I figured it out.

pep pepe

Joined: Jul 16, 2008
Posts: 1
Here is my code::

<pre name="code" class="core">
XMLGregorianCalendar xmlCal = null;
try {
xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
} catch (DatatypeConfigurationException e) {

Calendar now = Calendar.getInstance();
// We do a +1 below because XMLGregorianCalendar goes from 1 to 12
// while Calendar.MONTH goes from 0 to 11 !!!
GregorianCalendar c = xmlCal.toGregorianCalendar();
Date fecha = c.getTime();
java.sql.Date fechaSQL = new java.sql.Date(fecha.getTime());
Sergio Rossini

Joined: May 20, 2009
Posts: 6
More easy (found on this link):

Date convertedDate = xmlGregorianCalendar.toGregorianCalendar().getTime();
I agree. Here's the link: http://aspose.com/file-tools
subject: convert XMLGregorianCalender into java.util.date
Similar Threads
XSD TYPE dateTime - returns XMLGregorian calendar- how to convert into java.util.Date
How to add JAXB customization to a particular element of an xsd?
JAX-WS, stub generation isues
DST issue with GregorianCalendar
xml date conversion all date conversions