/**
* 参数值拼接
*
* @param obj
* @return
* @throws Exception
*/
private static StringBuffer getValue2Bean(Object obj) throws Exception {
Field[] fields = obj.getClass().getDeclaredFields();
StringBuffer value = new StringBuffer();
Object v = null;
for (Field field : fields) {
// v = BeanUtils.getProperty(obj, field.getName());//第一种(返回字符串类型)
v = ReflectUtil.getFieldValue(obj, field.getName());//第一种(返回原来类中类型)
if (v == null) {
value.append("," + v);
} else {
if (v instanceof String) {
value.append(",'" + v + "'");
} else if (v instanceof Date) {
value.append(",'" + DateUtil.getDateStr((Date) v) + "'");
} else {
value.append("," + v);
}
}
}
value = value.deleteCharAt(0);
return value;
}
String v = BeanUtils.getProperty(obj, field.getName());//第一种(返回字符串类型)
Object object = ReflectUtil.getFieldValue(obj, field.getName());//第一种返回原来类中类型,例如日期,数字,字符串等