code: public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(final Date date) {
          try {
              GregorianCalendar cal = new GregorianCalendar();
              cal.setTime(date);
              XMLGregorianCalendar calXml = DatatypeFactory.newInstance().newXMLGregorianCalendar(
                      cal.get(Calendar.YEAR),
                      cal.get(Calendar.MONTH) + 1,
                      cal.get(Calendar.DAY_OF_MONTH),
                      cal.get(Calendar.HOUR_OF_DAY),
                      cal.get(Calendar.MINUTE),
                      cal.get(Calendar.SECOND),
                      cal.get(Calendar.MILLISECOND),
                      0);
              return calXml;
          } catch (DatatypeConfigurationException e) {
              throw new SwidException("Cannot convert date", e);
          }
      }
docs: Convert {@link Date} to {@link XMLGregorianCalendar}.
  
  @param date
  XML entity