public static String getFiledValueByName(String fieldName, Object object) throws Exception { String result = null; try { if (StringUtils.hasText(fieldName)) { String methodName = ""; if(StringUtils.hasText(fieldName)){ methodName = "get"+fieldName.substring(0, 1).toUpperCase()+fieldName.substring(1); Method method = object.getClass().getMethod(methodName, new Class[] {}); Object obj = method.invoke(object, new Object[] {}); if (obj != null) { if(obj instanceof Timestamp){ result = DateTimeUtils.toString((Timestamp)obj, DateTimeUtils.DT_FMT_YYYYMMDDHHMMSS_SLASH); }else if(obj instanceof Date){ result = DateTimeUtils.toString((Date)obj, DateTimeUtils.DT_FMT_YYYYMMDD_SLASH); }else{ result = obj.toString(); } } } } } catch (Exception e) { throw e; } return result; }