class HerdDateUtils extends DateUtils {

    public static XMLGregorianCalendar getXMLGregorianCalendarValue(Date date)
    {
        GregorianCalendar gregorianCalendar = new GregorianCalendar();
        if (date != null)
        {
            gregorianCalendar.setTime(date);
        }

        try
        {
            return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
        }
        catch (DatatypeConfigurationException ex)
        {
            throw new IllegalStateException("Failed to create a new instance of DataTypeFactory.", ex);
        }
    }

}