title: How to tell Apache CXF to use java.util.Date in Spring Configuration
body: <p>I am Using CXF to host web services <strong>in a Spring context</strong>, which makes JAX-WS the default binding. And I'm using Java-First, which means annotated endpoint interfaces and classes.</p>
  
  <p>Since default binding for JAX-WS uses <code>XMLGregorianCalendar</code> class for dates, when I call my web service passing a <code>java.util.Date</code> it is converted to <code>XMLGregorianCalendar</code> on the server.</p>
  
  <p>There are many posts and documentation on how to change this to bind date values to <code>java.util.Date</code>, but all are related to wsdl2java tool, such as:</p>
  
  <pre><code>&lt;jaxws:bindings wsdlLocation="YOUR_WSDL_LOCATION"
            xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"&gt;
    &lt;jaxws:bindings  node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='THE_NAMESPACE_OF_YOUR_SCHEMA']"&gt;
        &lt;jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
          &lt;jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
                        parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
                        printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/&gt;
        &lt;/jxb:globalBindings&gt;
    &lt;/jaxws:bindings&gt;
  &lt;/jaxws:bindings&gt;
  </code></pre>
  
  <p>Since I'm using Spring, I'm looking for a way to do this in Spring context configuration files (or CXF configuration files). A snippet of my file:</p>
  
  <pre><code>&lt;jaxws:endpoint id="jaxwsDocumentGroupWsEndpoint" implementor="#documentGroupWsEndpoint" address="/documentGroup"&gt;
  &lt;!-- SOMETHING TO WRITE HERE TO TELL CXF TO USE java.util.Date ??? --&gt;
  &lt;/jaxws:endpoint&gt;
  </code></pre>