|
@@ -563,16 +563,36 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
else if(modelName.equals("startDate")){
|
|
|
if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- task.setStartDate(LocalDateTime.parse(cell.getStringCellValue(),df));
|
|
|
+ try {
|
|
|
+ int count = Integer.parseInt(cell.getStringCellValue());
|
|
|
+ // Excel中的日期序列号的基准日期是1900年1月1日
|
|
|
+ LocalDate baseDate = LocalDate.of(1900, 1, 1);
|
|
|
+ LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
|
|
|
+ task.setStartDate(date.atStartOfDay());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
|
|
|
+ msg.setError("日期时间格式不正确,应该是yyyy/MM/dd");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if(modelName.equals("endDate")){
|
|
|
if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- task.setEndDate(LocalDateTime.parse(cell.getStringCellValue(),df));
|
|
|
+ try {
|
|
|
+ int count = Integer.parseInt(cell.getStringCellValue());
|
|
|
+ // Excel中的日期序列号的基准日期是1900年1月1日
|
|
|
+ LocalDate baseDate = LocalDate.of(1900, 1, 1);
|
|
|
+ LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
|
|
|
+ task.setEndDate(date.atStartOfDay());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
|
|
|
+ msg.setError("日期时间格式不正确,应该是yyyy/MM/dd");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|