1212import java .time .Instant ;
1313import java .time .Duration ;
1414import java .time .LocalDateTime ;
15+ import java .time .temporal .ChronoUnit ;
1516import java .util .HashMap ;
1617import java .util .List ;
1718import java .util .Map ;
@@ -184,7 +185,7 @@ public StartScheduleResponseDto startSchedule(Long userId, UUID scheduleId) {
184185 assertScheduleNotFinished (schedule );
185186
186187 if (schedule .getStartedAt () == null ) {
187- schedule .startSchedule (Instant . now ());
188+ schedule .startSchedule (nowForPersistence ());
188189 freezePreparationSnapshotIfNeeded (schedule );
189190 scheduleRepository .save (schedule );
190191 }
@@ -277,7 +278,7 @@ public List<LatenessHistoryResponse> getLatenessHistory(Long userId) {
277278 // 지각 시간 업데이트
278279 @ Transactional
279280 public void updateLatenessTime (Schedule schedule , Integer latenessTime ) {
280- schedule .finish (latenessTime , Instant . now ());
281+ schedule .finish (latenessTime , nowForPersistence ());
281282 scheduleRepository .save (schedule );
282283 }
283284
@@ -300,7 +301,7 @@ public void finishSchedule(Long userId, UUID scheduleId, FinishPreparationDto fi
300301 throw new GeneralException (SCHEDULE_NOT_STARTED );
301302 }
302303
303- schedule .finish (finishPreparationDto .getLatenessTime (), Instant . now ());
304+ schedule .finish (finishPreparationDto .getLatenessTime (), nowForPersistence ());
304305 scheduleRepository .save (schedule );
305306 userService .updatePunctualityScore (userId , schedule .getDoneStatus ());
306307 }
@@ -437,4 +438,8 @@ private Integer defaultNonNegative(Integer value) {
437438 return value == null ? 0 : Math .max (value , 0 );
438439 }
439440
441+ private Instant nowForPersistence () {
442+ return Instant .now ().truncatedTo (ChronoUnit .SECONDS );
443+ }
444+
440445}
0 commit comments