public Object convert(Class destClass, Object srcObj) { String result = (String) stringConverter.convert(destClass, srcObj); try { Constructor constructor = destClass.getConstructor(String.class); // TODO Check, but not catch return constructor.newInstance(result); } catch (NoSuchMethodException e) { // just return the string return result; } catch (Exception e) { throw new ConversionException(e); } }
public Object convert(Class destClass, Object srcObj) { String result = (String) stringConverter.convert(destClass, srcObj); try { Constructor constructor = destClass.getConstructor(String.class); // TODO // Check, // but // not // catch return constructor.newInstance(result); } catch (NoSuchMethodException e) { // just return the string return result; } catch (Exception e) { throw new ConversionException(e); } }
public Object convert(Object srcFieldValue, Class destFieldClass, DateFormatContainer dateFormatContainer) { if (srcFieldValue == null || destFieldClass == null || (srcFieldValue.equals("") && !destFieldClass.equals(String.class))) { return null; } Converter converter = getPrimitiveOrWrapperConverter(destFieldClass, dateFormatContainer); try { return converter.convert(destFieldClass, srcFieldValue); } catch (org.apache.commons.beanutils.ConversionException e) { throw new org.dozer.converters.ConversionException(e); } }
public Object convert(Object srcFieldValue, Class destFieldClass, DateFormatContainer dateFormatContainer) { if (srcFieldValue == null || destFieldClass == null || (srcFieldValue .equals("") && !destFieldClass.equals(String.class))) { return null; } Converter converter = getPrimitiveOrWrapperConverter(destFieldClass, dateFormatContainer); try { return converter.convert(destFieldClass, srcFieldValue); } catch (org.apache.commons.beanutils.ConversionException e) { throw new org.dozer.converters.ConversionException(e); } }
result.setTime(new Date(dateFormat.parse((String) srcObj).getTime())); } catch (ParseException e) { throw new ConversionException("Unable to parse source object using specified date format", e); result.setTime(new Date(Long.parseLong(srcObj.toString()))); } catch (NumberFormatException e) { throw new ConversionException("Unable to determine time in millis of source object", e);
result.setTime(new Date(dateFormat.parse((String) srcObj).getTime())); } catch (ParseException e) { throw new ConversionException("Unable to parse source object using specified date format", e); result.setTime(new Date(Long.parseLong(srcObj.toString()))); } catch (NumberFormatException e) { throw new ConversionException("Unable to determine time in millis of source object", e);
result.setTime(new Date(time)); } catch (ParseException e) { throw new ConversionException("Unable to parse source object using specified date format", e); result.setTime(new Date(time)); } catch (NumberFormatException e) { throw new ConversionException("Unable to determine time in millis of source object", e);
result.setTime(new Date(time)); } catch (ParseException e) { throw new ConversionException("Unable to parse source object using specified date format", e); result.setTime(new Date(time)); } catch (NumberFormatException e) { throw new ConversionException("Unable to determine time in millis of source object", e);
throw new ConversionException("Unable to parse source object using specified date format", e); time = Long.parseLong(srcObj.toString()); } catch (NumberFormatException e) { throw new ConversionException("Unable to determine time in millis of source object", e); throw new ConversionException(e);
throw new ConversionException("Unable to parse source object using specified date format", e); time = Long.parseLong(srcObj.toString()); } catch (NumberFormatException e) { throw new ConversionException("Unable to determine time in millis of source object", e); throw new ConversionException(e);