Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.UUID;

import com.newzet.api.article.domain.Article;
import com.newzet.api.common.util.UtcTimeZoneConverter;

import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -56,8 +57,8 @@ public Article toDomain() {
isRead,
isLike,
isShare,
createdAt,
deletedAt
UtcTimeZoneConverter.toKst(createdAt),
UtcTimeZoneConverter.toKst(deletedAt)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ResponseEntity<SuccessResponse<ArticleListResponse>> getMonthlyArticleLis
}

@GetMapping("/{articleId}")
// @RequireAuth
@RequireAuth
@Operation(summary = "아티클 단건 조회",
description = "유저가 구독한 뉴스레터의 아티클을 조회한다.")
public ResponseEntity<SuccessResponse<ArticleContentResponse>> getArticle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.time.LocalDateTime;
import java.util.UUID;

import com.newzet.api.common.util.UtcTimeZoneConverter;

public record ArticleDetailResponse(
String id,
String newsletterName,
Expand All @@ -15,7 +17,7 @@ public record ArticleDetailResponse(
public static ArticleDetailResponse of(UUID id, String newsletterName, String newsletterImgUrl,
String title, boolean isRead, LocalDateTime createdAt) {
return new ArticleDetailResponse(id.toString(), newsletterName, newsletterImgUrl, title,
isRead, createdAt.toString());
isRead, UtcTimeZoneConverter.toKst(createdAt).toString());
}

public int getDay() {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/newzet/api/common/util/UtcTimeZoneConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.newzet.api.common.util;

import java.time.LocalDateTime;
import java.time.ZoneId;

public class UtcTimeZoneConverter {

private static final ZoneId UTC = ZoneId.of("UTC");
private static final ZoneId KST = ZoneId.of("Asia/Seoul");

public static LocalDateTime toKst(LocalDateTime utcDateTime) {
if (utcDateTime == null) {
return null;
}
return utcDateTime.atZone(UTC)
.withZoneSameInstant(KST)
.toLocalDateTime();
}
}
Loading