/** * Splits the conversion into date-based and calendar-based. * * @param <U> The type to be converted to * @param value The string to be converted into a date/time type or vice * versa * @param fieldType The class of the destination field * @return The object resulting from the conversion * @throws CsvDataTypeMismatchException If a non-convertible type is * passed in, or if the conversion fails */ private <U> U convertCommon(Object value, Class<U> fieldType) throws CsvDataTypeMismatchException { U o; Class conversionClass = (fieldType == String.class)?value.getClass():fieldType; // Send to the proper sub-method if (Date.class.isAssignableFrom(conversionClass)) { o = convertDate(value, fieldType); } else if (Calendar.class.isAssignableFrom(conversionClass) || XMLGregorianCalendar.class.isAssignableFrom(conversionClass)) { o = convertCalendar(value, fieldType); } else { throw new CsvDataTypeMismatchException(value, fieldType, ResourceBundle.getBundle(ICSVParser.DEFAULT_BUNDLE_NAME, errorLocale).getString(CSVDATE_NOT_DATE)); } return o; }