From 2c343220615216ea690631a53541badfda1ea657 Mon Sep 17 00:00:00 2001 From: baoliang Date: Mon, 15 Apr 2019 17:29:55 +0800 Subject: [PATCH] fix bug: error start date and end date in task record --- .../cn/escheduler/common/utils/DateUtils.java | 2 +- .../java/cn/escheduler/dao/TaskRecordDao.java | 5 ++-- .../cn/escheduler/dao/model/TaskRecord.java | 24 +++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java b/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java index a40725fe16..11dc6bfbf6 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java @@ -72,7 +72,7 @@ public class DateUtils { public static Date parse(String date,String format){ try { return new SimpleDateFormat(format).parse(date); - } catch (ParseException e) { + } catch (Exception e) { logger.error("error while parse date:" + date, e); } return null; diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/TaskRecordDao.java b/escheduler-dao/src/main/java/cn/escheduler/dao/TaskRecordDao.java index ebc206f9ac..c2c82b77f8 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/TaskRecordDao.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/TaskRecordDao.java @@ -17,6 +17,7 @@ package cn.escheduler.dao; import cn.escheduler.common.Constants; +import cn.escheduler.common.utils.DateUtils; import cn.escheduler.dao.model.TaskRecord; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; @@ -201,8 +202,8 @@ public class TaskRecordDao { taskRecord.setProcId(resultSet.getInt("PROC_ID")); taskRecord.setProcName(resultSet.getString("PROC_NAME")); taskRecord.setProcDate(resultSet.getString("PROC_DATE")); - taskRecord.setStartDate(resultSet.getDate("STARTDATE")); - taskRecord.setEndDate(resultSet.getDate("ENDDATE")); + taskRecord.setStartTime(DateUtils.stringToDate(resultSet.getString("STARTDATE"))); + taskRecord.setEndTime(DateUtils.stringToDate(resultSet.getString("ENDDATE"))); taskRecord.setResult(resultSet.getString("RESULT")); taskRecord.setDuration(resultSet.getInt("DURATION")); taskRecord.setNote(resultSet.getString("NOTE")); diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/model/TaskRecord.java b/escheduler-dao/src/main/java/cn/escheduler/dao/model/TaskRecord.java index 17bd073366..82e96061b8 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/model/TaskRecord.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/model/TaskRecord.java @@ -46,12 +46,12 @@ public class TaskRecord { /** * start date */ - private Date startDate; + private Date startTime; /** * end date */ - private Date endDate; + private Date endTime; /** * result @@ -136,20 +136,20 @@ public class TaskRecord { this.procDate = procDate; } - public Date getStartDate() { - return startDate; + public Date getStartTime() { + return startTime; } - public void setStartDate(Date startDate) { - this.startDate = startDate; + public void setStartTime(Date startTime) { + this.startTime = startTime; } - public Date getEndDate() { - return endDate; + public Date getEndTime() { + return endTime; } - public void setEndDate(Date endDate) { - this.endDate = endDate; + public void setEndTime(Date endTime) { + this.endTime = endTime; } public String getResult() { @@ -238,8 +238,8 @@ public class TaskRecord { +" proc id:" + procId + " proc name:" + procName + " proc date: " + procDate - + " start date:" + startDate - + " end date:" + endDate + + " start date:" + startTime + + " end date:" + endTime + " result : " + result + " duration : " + duration + " note : " + note