日期格式转换
public Date buildTime(String blanceTime) { String[] parsePatterns = {"yyyy-MM-dd","yyyy/MM/dd"}; Date formattedDate = null; try { //防止被Excel 转换成数字 String regex = "^(\\d+(\\.\\d+)?)$"; if (blanceTime.matches(regex)) { Date dateToReturn = DateUtil.getJavaDate(Integer.parseInt(blanceTime)); formattedDate = dateFormat.parse(dateFormat.format(dateToReturn)); } else { formattedDate = DateUtils.parseDateStrictly(blanceTime, parsePatterns); } } catch (Exception e) { logger.error("解析日期格式失败:",e); } return formattedDate; }