public Object convert(Class destClass, Object srcObj) {
        final Class srcFieldClass = srcObj.getClass();

        long time;
        int nanos = 0;
        if (Calendar.class.isAssignableFrom(srcFieldClass)) {
            Calendar inVal = (Calendar)srcObj;
            time = inVal.getTime().getTime();
        } else if (Timestamp.class.isAssignableFrom(srcFieldClass)) {
            Timestamp timestamp = (Timestamp)srcObj;
            time = timestamp.getTime();
            nanos = timestamp.getNanos();
        } else if (java.util.Date.class.isAssignableFrom(srcFieldClass)) {
            time = ((java.util.Date)srcObj).getTime();
        } else if (XMLGregorianCalendar.class.isAssignableFrom(srcFieldClass)) {
            time = ((XMLGregorianCalendar)srcObj).toGregorianCalendar().getTimeInMillis();
        } else if (dateFormat != null && String.class.isAssignableFrom(srcObj.getClass())) {
            try {
                if ("".equals(srcObj)) {
                    return null;
                }
                time = dateFormat.parse((String)srcObj).getTime();
            } catch (ParseException e) {
                throw new ConversionException("Unable to parse source object using specified date format", e);
            }
            // Default conversion
        } else {
            try {
                time = Long.parseLong(srcObj.toString());
            } catch (NumberFormatException e) {
                throw new ConversionException("Unable to determine time in millis of source object", e);
            }
        }

        try {
            if (Calendar.class.isAssignableFrom(destClass)) {
                Constructor constructor = destClass.getConstructor();
                Calendar result = (Calendar)constructor.newInstance();
                result.setTimeInMillis(time);
                return result;
            }

            if (dateFormat != null && String.class.isAssignableFrom(destClass)) {
                return dateFormat.format(new java.util.Date(time));
            }

            Constructor constructor = destClass.getConstructor(Long.TYPE);
            Object result = constructor.newInstance(time);
            if (nanos != 0 && (Timestamp.class.isAssignableFrom(destClass))) {
                ((Timestamp)result).setNanos(nanos);
            }
            return result;
        } catch (Exception e) {
            throw new ConversionException(e);
        }
    }
Internal convector for handling Date/Time conversions.
<p>
Supported source data types include java.util.Date,
java.sql.Date, java.sql.Time, java.sql.Timestamp, java.util.Calendar, javax.xml.datatype.XMLGregorianCalendar,
java.lang.String and any objects that return a number of milliseconds applicable to java.lang.Long
format in their toString() form.
<p>
Supported return data types are all Date/Time types, which are based on a timestamp constructor
(e.g. new MyDate(new Long(1))). Calendar return type is also supported.
<p>
Only intended for internal use.
core/src/main/java/com/github/dozermapper/core/converters/DateConverter.java