File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes convert XMLGregorianCalender into Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "convert XMLGregorianCalender into" Watch "convert XMLGregorianCalender into" New topic

convert XMLGregorianCalender into

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:
subject: convert XMLGregorianCalender into
It's not a secret anymore!