You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/04/28 09:20:25 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #9830: [Bug-9829][Api] Fix schedule timezone

ruanwenjun commented on code in PR #9830:
URL: https://github.com/apache/dolphinscheduler/pull/9830#discussion_r860669600


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java:
##########
@@ -173,8 +174,12 @@ public Map<String, Object> insertSchedule(User loginUser,
             putMsg(result, Status.START_TIME_BIGGER_THAN_END_TIME_ERROR);
             return result;
         }
-        scheduleObj.setStartTime(scheduleParam.getStartTime());
-        scheduleObj.setEndTime(scheduleParam.getEndTime());
+
+        // transform timezone from system default timezone to schedule timezone
+        Date startTime = DateUtils.transformTimezoneDate(scheduleParam.getStartTime(), scheduleParam.getTimezoneId());
+        Date endTime = DateUtils.transformTimezoneDate(scheduleParam.getEndTime(), scheduleParam.getTimezoneId());
+        scheduleObj.setStartTime(startTime);
+        scheduleObj.setEndTime(endTime);

Review Comment:
   I think there is no need to transform the data when insert into database. And we also no need to transform the data when query from database and return to front-end. Since we also insert the timezoneId into database.
   e.g. If front-end give us a scheme time `2022-4-28 00:00:00`, timezone is UTC, our server is at Shanghai. Then we can directly insert the origin data into database, and return the `2022-4-28 00:00:00`, timezone `UTC` to front-end, when do a query.
   We only need to do the transform when we give the schedule time into quartz.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org