Skip to content

Commit

Permalink
[refactor] 서머타임에 영향을 받는 ZoneId 대신 엄밀한 시간을 가지는 ZoneOffset을 의존하도록 변경 (#115
Browse files Browse the repository at this point in the history
)
  • Loading branch information
blaxsior committed Aug 22, 2024
1 parent d5aef5d commit e6c5c0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public Boolean createComment(String userId, String eventFrameId, CreateCommentDt

// 오늘의 시작과 끝 시각 계산
LocalDate today = LocalDate.now();
Instant startOfDay = today.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
Instant endOfDay = today.atTime(LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant();
Instant startOfDay = today.atStartOfDay().atZone(ZoneOffset.systemDefault()).toInstant();
Instant endOfDay = today.atTime(LocalTime.MAX).atZone(ZoneOffset.systemDefault()).toInstant();

// 오늘 유저가 인터렉션에 참여하지 않았다면 예외처리
boolean participated = participationInfoRepository.existsByEventUserAndDrawEventAndDateBetween(eventUser, drawEvent, startOfDay, endOfDay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Date;

public class DateUtil {
public static Date localDateTimeToDate(LocalDateTime localDateTime) {
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
Instant instant = localDateTime.atZone(ZoneOffset.systemDefault()).toInstant();

return Date.from(instant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ protected void participateAtDate(String eventId, String eventUserId, Instant dat

if(!eventUser.getEventFrameId().equals(event.getEventFrameId())) throw new EventException(ErrorCode.CANNOT_PARTICIPATE);

LocalDate today = LocalDate.ofInstant(date, ZoneId.systemDefault());
// TODO: 이벤트 정보를 저장할 때 타임존을 함께 저장하도록 변경. 현재는 서버 배포 환경 시간을 기반으로 동작하도록 설정
LocalDate today = LocalDate.ofInstant(date, ZoneOffset.systemDefault());

// 이벤트 기간 안에 있는지 검사
if(event.getStartTime().isAfter(date) || event.getEndTime().isBefore(date))
Expand Down

0 comments on commit e6c5c0f

Please sign in to comment.