There are several ways to convert XMLGregorianCalendar to Date in Java.
You can convert XMLGregorianCalendar to either java.util.Date or java.sql.Date based upon
your need. JAXB (Java API/Architecture for XML
Bindings) is a popular framework to create XML documents from Java
Objects and Java objects from XML files. JAXB also helps to create Java classes
from XML Schema file (.XSD file). By default JAXB maps XSD data type xs:date, xs:time and xs:dateTime to XMLGregorianCalendar in Java,
but you can configure XJC to create java.util.Date objects
instead of javax.xml.datatype.XMLGregorianCalendar. Since java.util.Date
is most popular way of dealing with date and time in Java, we often need to
convert XMLGregorianCalendar instance to Date instance
in Java. Thankfully by using Java API, we can easily do this conversion of XMLGregorianCalendar to Date and Date to XMLGregorianCalendar in Java. By
the way, It's good to remember that XML Schema has three different types which
can represent either date, time or both, while java.util.Date contains
date and time information together. In this Java and XML tutorial, we will see
example of converting
XMLGregorianCalendar to Date and inverse in Java.

XMLGregorianCalendar to Date to
XMLGregorianCalendar

Here is a Java
program, which converts XMLGregorianCalendar instances
to java.util.Date instances. We have two method, one which takes XMLGregorianCalendar and return
java.util.Date, and other which takes Date and return
XMLGregorianCalendar.

importjava.util.Date;

importjava.util.GregorianCalendar;

importjava.util.logging.Level;

importjava.util.logging.Logger;

importjavax.xml.datatype.DatatypeConfigurationException;

importjavax.xml.datatype.DatatypeFactory;

importjavax.xml.datatype.XMLGregorianCalendar;

/**

* Java program to convert
XMLGregorianCalendar to Date and inverse i.e. java.util.Date

* to XMLGregorianCalendar.
If you are using XJC to create Java classes from XML Schema

java.util.Date from XMLGregorianCalendar in Java:SunJan2723:45:23VET2013

Important
point to note:

Few points which is worth knowing while converting XMLGregorianCalendar
to Date in Java.

1) XML Schema has different data type for date, time and dateTime e.g. xsd:date, xsd:time and xsd:dateTime, By
default JAXB XJC maps all these to XMLGregorianCalendar in Java.

2) It's possible to customize XJC to generate Date
instead of XMLGregorianCalendar for xs:date, xs:time and xs:dateTime data
types. I will write about that later, but you can still explores this option.

3) While creating instance of GregorianCalendar, its
better to use constructor
instead calling GregorianCalendar.getInstance() because
it's similar to Calendar.getInstance() and can return different
type of Calendar based upon Locale settings e.g. BuddhistCalendar for Thai
locale or JapaneseImperialCalendar for Japan.
By using constructor, you also removes type casting because getInstance() return
instance of java.util.Calendar, and prevents ClassCastException
in Java.