From 175ef218d51d9b9da036fe8685c7fe9077f58f26 Mon Sep 17 00:00:00 2001 From: Koda Date: Tue, 16 May 2017 22:01:04 +0900 Subject: [PATCH] #724 Fix the date of survey report from UTC to local time --- .../knowledge/control/protect/SurveyControl.java | 5 +++++ .../knowledge/entity/SurveyAnswersEntity.java | 16 ++++++++++++++++ src/main/webapp/js/survey-answers.js | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java b/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java index 5f2ef6cf4..afe817e91 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java @@ -31,6 +31,7 @@ import org.support.project.web.control.service.Get; import org.support.project.web.control.service.Post; import org.support.project.web.exception.InvalidParamException; +import org.support.project.web.logic.DateConvertLogic; import net.arnx.jsonic.JSONException; @@ -239,6 +240,10 @@ public Boundary report() throws InvalidParamException { return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); } SurveyReport report = SurveyLogic.get().loadAnswers(knowledgeId, getLoginUserId()); + List answers = report.getAnswers(); + for (SurveyAnswersEntity ans : answers) { + ans.setLocalDatetime(DateConvertLogic.get().convertDate(ans.getInsertDatetime(), getRequest())); + } return send(report); } diff --git a/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java b/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java index 6e9782bd4..bb065c63c 100644 --- a/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java @@ -19,6 +19,8 @@ public class SurveyAnswersEntity extends GenSurveyAnswersEntity { /** 回答者の名前 */ private String userName; + /** 回答集計を操作しているユーザのタイムゾーン/ロケールでの日付文字列 */ + private String localDatetime; /** SerialVersion */ private static final long serialVersionUID = 1L; @@ -76,4 +78,18 @@ public void setUserName(String userName) { this.userName = userName; } + /** + * @return the localDatetime + */ + public String getLocalDatetime() { + return localDatetime; + } + + /** + * @param localDatetime the localDatetime to set + */ + public void setLocalDatetime(String localDatetime) { + this.localDatetime = localDatetime; + } + } diff --git a/src/main/webapp/js/survey-answers.js b/src/main/webapp/js/survey-answers.js index bd4f3fda9..147dab700 100644 --- a/src/main/webapp/js/survey-answers.js +++ b/src/main/webapp/js/survey-answers.js @@ -35,7 +35,8 @@ $(document).ready(function() { result.answers.forEach(function(answer) { var row = {}; - row.answer_datetime = moment(answer.insertDatetime, 'YYYY-MM-DD HH:mm:ss.SSS').format('YYYY-MM-DD HH:mm'); + row.answer_datetime = answer.localDatetime; +// row.answer_datetime = moment(answer.insertDatetime, 'YYYY-MM-DD HH:mm:ss.SSS').format('YYYY-MM-DD HH:mm'); row.answer_user = answer.userName; answer.items.forEach(function(answerItem) {