excel导入,时间格式是5位数的数字的问题
前端传入参数 data
接受前端的实体时间格式:
@JsonFormat( locale="zh", timezone="GMT+8",pattern="yyyy-MM-dd HH:mm:ss")
private Date payTime;
##
int day = (int) data.getPayTime().getTime();
if (String.valueOf(day).length() == 5) {
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd");
Date date = df.parse("1900/01/01");
Date payTime = getDate(date, (day - 2));
data.setPayTime(payTime);
} catch (ParseException e) {
e.printStackTrace();
}
}
##
public static Date getDate(Date date, int day) {
Calendar calendar= Calendar.getInstance();
try {
calendar.setTime(date);
calendar.add(Calendar.DATE, day);
return calendar.getTime();
} catch (Exception e) {
return null;
}
}