List<Object> list = techQualificationsDao.getDatas(r.getCode(), where, null, null); Class<?> childClass = null; Field childF = null; Field childF2 = null; Object fieldValue = null; for (Object o : list) { try { childClass = o.getClass(); childF = childClass.getDeclaredField("fawensj"); childF.setAccessible(true); fieldValue = childF.get(o); Date date = (Date) fieldValue; SimpleDateFormat fs = new SimpleDateFormat("yyyy-MM-dd"); childF2 = childClass.getDeclaredField("fawensjStr"); childF2.setAccessible(true); childF2.set(o,fs.format(date)); } catch (Exception e) { e.printStackTrace(); } } return list;
java反射操作Object对象里的属性值(取值和更新value)
最新推荐文章于 2023-01-04 20:06:05 发布