title: How To Populate XMLGregorianCalendar()
body: <p>I need to populate a JAX Bean from XML, however there is no setter method.  I get the following message below</p>
  
  <pre><code> Failed to invoke public javax.xml.datatype.XMLGregorianCalendar() with no args
  </code></pre>
  
  <p>I wrote the following methods to take a date and transform it to XMLGregorianCalendar, and then call a setter in my wrapper class.  However I still get the exception.  Is there a standard way of handling this data type that I am overlooking?  Maybe my wrapper class is not calling it, but Netbeans won't allow me to attach a debugger to it for some reason.</p>
  
  <pre><code>public XMLGregorianCalendar asXMLGregorianCalendar(java.util.Date date) throws DatatypeConfigurationException {
      DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
      if (date == null) {
          return null;
      } else {
          GregorianCalendar gc = new GregorianCalendar();
          gc.setTimeInMillis(date.getTime());
          return datatypeFactory.newXMLGregorianCalendar(gc);
      }
  }
  </code></pre>
  
  <p>The setter in the Bean is below</p>
  
  <pre><code>public void setDeliveryDate(XMLGregorianCalendar value) {
      this.deliveryDate = value;
  }
  </code></pre>