php网站有哪些,男女做羞羞事试看网站,宁波网站建设策划公司排名,广告网店文件导入时#xff0c;时间类型通常不能直接导出#xff0c;以下方法为批量处理类中日期类型转字符串类型。
Date/Datetime -- String(yyyy-mm-dd)Field[] declaredFields HrAviationstudentMonitorDTO.class.getDeclaredFields();
for (Field field : declaredFields) …文件导入时时间类型通常不能直接导出以下方法为批量处理类中日期类型转字符串类型。
Date/Datetime -- String(yyyy-mm-dd)Field[] declaredFields HrAviationstudentMonitorDTO.class.getDeclaredFields();
for (Field field : declaredFields) {try {field.setAccessible(true);// 如果类型是Dateif ( field.getType().getName().equals(java.util.Date)) {String fieldName field.getName();// createTime和modfiyTime不需要导出if (createTime.equals(fieldName) || modfiyTime.equals(fieldName)) continue;Method m dto.getClass().getMethod(get getMethodName(fieldName));Date val (Date) m.invoke(dto);if (val ! null) {String val2 DateUtil.format(val);Field field1 HrAviationstudentMonitorExcel.class.getDeclaredField(fieldName);if (ObjectUtil.isNotEmpty(field1)) {field1.setAccessible(true);field1.set(excel, val2);}}}}catch (Exception e) {log.error(trainee:hrAviationstudentMonitor:export_____Exception: e.getMessage());e.printStackTrace();}
}
// 把一个字符串的第一个字母大写
private static String getMethodName(String fildeName) throws Exception{byte[] items fildeName.getBytes();items[0] (byte) ((char) items[0] - a A);return new String(items);
}
public static final String DATE_PATTERN yyyy-MM-dd;
/*** 日期格式化 日期格式为yyyy-MM-dd** param date 日期* return 返回yyyy-MM-dd格式日期*/
public static String format(Date date) {return format(date, DATE_PATTERN);
}/*** 日期格式化 日期格式为yyyy-MM-dd** param date 日期* param pattern 格式如DateUtils.DATE_TIME_PATTERN* return 返回yyyy-MM-dd格式日期*/
public static String format(Date date, String pattern) {if (date ! null) {SimpleDateFormat df new SimpleDateFormat(pattern);return df.format(date);}return null;
}