Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor:notice 날짜 포맷팅 수정 #159

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions src/main/java/com/gamzabat/algohub/common/DateFormatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
return dateTime.format(formatter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 이렇게 포맷하면 뒤에 AM,PM도 붙나요??

image

뷰에 보심 AM, PM도 있습니다..!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 이렇게 포맷하면 뒤에 AM,PM도 붙나요??

image 뷰에 보심 AM, PM도 있습니다..!

요렇게 하면 'AM/PM' 이 안 붙는답니다..!
HH:mm a 라고 해야 AM PM이 붙는다고 합니다 감사합니다~

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static GetNoticeResponse toDTO(Notice notice) {
.title(notice.getTitle())
.content(notice.getContent())
.category(notice.getCategory())
.createAt(DateFormatUtil.formatDate(notice.getCreatedAt().toLocalDate()))
.createAt(DateFormatUtil.formatDateTimeForNotice(notice.getCreatedAt()))
.build();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,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);
}

Expand Down
Loading