Skip to content

Commit

Permalink
Merge pull request #116 from UMC-ON/feat/boardnpost
Browse files Browse the repository at this point in the history
Fix: 정보/자유게시글 조회 시 작성 시간을 한국시간으로 변환
  • Loading branch information
isuHan authored Dec 6, 2024
2 parents 348cdcc + 5a1793d commit 9621468
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -67,6 +68,11 @@ public static PostResponseDTO from(Post post, boolean includeCommentCount) {
.userStatus(userStatus)
.build();

LocalDateTime createdAtInSeoul = post.getCreatedAt()
.atZone(ZoneId.of("UTC"))
.withZoneSameInstant(ZoneId.of("Asia/Seoul"))
.toLocalDateTime();

return PostResponseDTO.builder()
.postId(post.getId())
.boardType(post.getBoard().getType())
Expand All @@ -75,7 +81,7 @@ public static PostResponseDTO from(Post post, boolean includeCommentCount) {
.content(post.getContent())
.isAnonymous(post.getIsAnonymous())
.isAnonymousUniv(post.getIsAnonymousUniv())
.createdAt(post.getCreatedAt())
.createdAt(createdAtInSeoul)
.commentCount(includeCommentCount ? commentCount : 0)
.imageUrls(post.getImages().stream().map(UuidFile::getFileUrl).collect(Collectors.toList()))
.build();
Expand Down

0 comments on commit 9621468

Please sign in to comment.