public static void main(String[] args) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
FrontUser frontUser = new FrontUser();
Method setTimeMethod = null;
Method getTimeMethod = null;
Class<?> entityClass = frontUser.getClass();
getTimeMethod = entityClass.getMethod("getPhone");
Object createTime = getTimeMethod.invoke(frontUser);
if (createTime == null) {
setTimeMethod = entityClass.getMethod("setPhone", String.class);
setTimeMethod.invoke(frontUser, DateUtil.getDate());//当前时间
}
System.out.println(frontUser);// phone就是当前时间
}