diff --git a/src/main/java/com/gamzabat/algohub/common/DateFormatUtil.java b/src/main/java/com/gamzabat/algohub/common/DateFormatUtil.java index 22bb9e76..bfdf810d 100644 --- a/src/main/java/com/gamzabat/algohub/common/DateFormatUtil.java +++ b/src/main/java/com/gamzabat/algohub/common/DateFormatUtil.java @@ -14,4 +14,9 @@ public static String formatDateTime(LocalDateTime dateTime) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss"); return dateTime.format(formatter); } + + public static String formatDateTimeForNotice(LocalDateTime dateTime) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy/MM/dd HH:mm a"); + return dateTime.format(formatter); + } } diff --git a/src/main/java/com/gamzabat/algohub/feature/notice/dto/GetNoticeResponse.java b/src/main/java/com/gamzabat/algohub/feature/notice/dto/GetNoticeResponse.java index e6e0cbd3..b629bc48 100644 --- a/src/main/java/com/gamzabat/algohub/feature/notice/dto/GetNoticeResponse.java +++ b/src/main/java/com/gamzabat/algohub/feature/notice/dto/GetNoticeResponse.java @@ -21,7 +21,7 @@ public static GetNoticeResponse toDTO(Notice notice, boolean isRead) { .title(notice.getTitle()) .content(notice.getContent()) .category(notice.getCategory()) - .createAt(DateFormatUtil.formatDate(notice.getCreatedAt().toLocalDate())) + .createAt(DateFormatUtil.formatDateTimeForNotice(notice.getCreatedAt())) .isRead(isRead) .build(); } diff --git a/src/main/java/com/gamzabat/algohub/feature/notice/service/NoticeService.java b/src/main/java/com/gamzabat/algohub/feature/notice/service/NoticeService.java index db7abd25..ca423653 100644 --- a/src/main/java/com/gamzabat/algohub/feature/notice/service/NoticeService.java +++ b/src/main/java/com/gamzabat/algohub/feature/notice/service/NoticeService.java @@ -80,7 +80,7 @@ public GetNoticeResponse getNotice(@AuthedUser User user, Long noticeId) { .title(notice.getTitle()) .content(notice.getContent()) .category(notice.getCategory()) - .createAt(DateFormatUtil.formatDate(notice.getCreatedAt().toLocalDate())) + .createAt(DateFormatUtil.formatDateTimeForNotice(notice.getCreatedAt())) .isRead(true) .build(); } diff --git a/src/test/java/com/gamzabat/algohub/service/NoticeServiceTest.java b/src/test/java/com/gamzabat/algohub/service/NoticeServiceTest.java index 44833bca..fc57ebdf 100644 --- a/src/test/java/com/gamzabat/algohub/service/NoticeServiceTest.java +++ b/src/test/java/com/gamzabat/algohub/service/NoticeServiceTest.java @@ -185,7 +185,7 @@ void getNoticeSuccess_1() { assertThat(response.content()).isEqualTo("content"); assertThat(response.title()).isEqualTo("title"); assertThat(response.category()).isEqualTo("category"); - assertThat(response.createAt()).isEqualTo(DateFormatUtil.formatDate(LocalDateTime.now().toLocalDate())); + assertThat(response.createAt()).isEqualTo(DateFormatUtil.formatDateTimeForNotice(notice.getCreatedAt())); assertThat(response.noticeId()).isEqualTo(1000L); verify(noticeReadRepository, times(1)).save(any(NoticeRead.class)); }