Skip to content

Commit

Permalink
♻️ refactor/#130 : 5.2 온기 우편함 created date 속성 추가
Browse files Browse the repository at this point in the history
Signed-off-by: EunJiJung <[email protected]>
  • Loading branch information
bianbbc87 committed Nov 23, 2024
1 parent 769e3dd commit 3e82aa6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/daon/onjung/core/utility/DateTimeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class DateTimeUtil {
public static final DateTimeFormatter ISODateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public static final DateTimeFormatter ISOTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
public static final DateTimeFormatter KORDateFormatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일"); // 새로운 포맷터 추가
public static final DateTimeFormatter SHORTKORDateFormatter = DateTimeFormatter.ofPattern("yy년 MM월 dd일");
public static final DateTimeFormatter KORYearMonthDateFormatter = DateTimeFormatter.ofPattern("yyyy년 MM월"); // 새로운 포맷터 추가
public static final DateTimeFormatter DotSeparatedDateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
public static final DateTimeFormatter CustomDateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd (EEE)", Locale.KOREAN);
Expand Down Expand Up @@ -120,6 +121,16 @@ public static String convertLocalDateToKORString(LocalDateTime date) {
return date.format(KORDateFormatter);
}

/**
* LocalDateTime을 짧은 한국어 날짜 형식으로 변환 (yy년 MM월 dd일)
*
* @param date LocalDateTime
* @return String
*/
public static String convertLocalDateTimeToSHORTKORString(LocalDateTime date) {
return date.format(SHORTKORDateFormatter);
}

/**
* String(한국어 날짜 형식, yyyy년 MM월 dd일)을 LocalDate로 변환
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static class EventDto {
@JsonProperty("store_info")
private final StoreInfoDto storeInfo;

@NotNull(message = "created_date은 null일 수 없습니다.")
@JsonProperty("created_date")
private final String createdDate;

@NotNull(message = "onjung_type은 null일 수 없습니다.")
@JsonProperty("onjung_type")
private final EOnjungType onjungType;
Expand All @@ -70,6 +74,7 @@ public static class EventDto {
@Builder
public EventDto(
StoreInfoDto storeInfo,
String createdDate,
EOnjungType onjungType,
EStatus status,
String eventPeriod,
Expand All @@ -78,6 +83,7 @@ public EventDto(
String reportDate
) {
this.storeInfo = storeInfo;
this.createdDate = createdDate;
this.onjungType = onjungType;
this.status = status;
this.eventPeriod = eventPeriod;
Expand All @@ -88,6 +94,7 @@ public EventDto(

public static EventDto fromEntity(
StoreInfoDto storeInfo,
String createdDate,
EOnjungType onjungType,
EStatus status,
String eventPeriod,
Expand All @@ -98,6 +105,7 @@ public static EventDto fromEntity(

return EventDto.builder()
.storeInfo(storeInfo)
.createdDate(createdDate)
.onjungType(onjungType)
.status(status)
.eventPeriod(eventPeriod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public ReadOnjungEventOverviewResponseDto execute(
donation.getStore().getTitle(),
donation.getStore().getName()
),
DateTimeUtil.convertLocalDateTimeToSHORTKORString(donation.getCreatedAt()),
EOnjungType.fromString("DONATION"),
event.getStatus(),
DateTimeUtil.convertLocalDatesToDotSeparatedDatePeriod(event.getStartDate(), event.getEndDate()),
Expand All @@ -97,6 +98,7 @@ public ReadOnjungEventOverviewResponseDto execute(
receipt.getStore().getTitle(),
receipt.getStore().getName()
),
DateTimeUtil.convertLocalDateTimeToSHORTKORString(receipt.getCreatedAt()),
EOnjungType.fromString("RECEIPT"),
EStatus.COMPLETED,
DateTimeUtil.convertLocalDateToDotSeparatedDateTime(receipt.getCreatedAt().toLocalDate()),
Expand All @@ -112,6 +114,7 @@ public ReadOnjungEventOverviewResponseDto execute(
share.getStore().getTitle(),
share.getStore().getName()
),
DateTimeUtil.convertLocalDateTimeToSHORTKORString(share.getCreatedAt().atTime(0, 0)),
EOnjungType.fromString("SHARE"),
EStatus.COMPLETED,
DateTimeUtil.convertLocalDateToDotSeparatedDateTime(share.getCreatedAt()),
Expand Down

0 comments on commit 3e82aa6

Please sign in to comment.