直接转换,把list集合替换就好
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
Map<String, Object> map = null;
try {
map = (Map<String, Object>) PropertyUtils.describe(item);
map.remove("class");
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
listMap.add(map);
});
//下面是项目业务需要代码,时间转换用
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = null;
for (Map<String, Object> map : listMap) {
for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
if (stringObjectEntry.getValue() instanceof Long) {
format = simpleDateFormat.format(stringObjectEntry.getValue());
map.put(stringObjectEntry.getKey(), format);
}
}
}
}