From 0e274a130b694d854b4aad360e7ff1a72cc38e3e Mon Sep 17 00:00:00 2001 From: gol2580 Date: Wed, 17 Jan 2024 23:34:56 +0900 Subject: [PATCH] [fix] fix AuditEntity : String to LocalDateTime --- .../java/com/kimgreen/backend/domain/AuditEntity.java | 10 ++++++---- .../notification/dto/NotificationResponseDto.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/kimgreen/backend/domain/AuditEntity.java b/src/main/java/com/kimgreen/backend/domain/AuditEntity.java index 0920ed7..874af6f 100644 --- a/src/main/java/com/kimgreen/backend/domain/AuditEntity.java +++ b/src/main/java/com/kimgreen/backend/domain/AuditEntity.java @@ -19,18 +19,20 @@ public class AuditEntity { @CreatedDate - private String createdAt; + private LocalDateTime createdAt; @LastModifiedDate - private String modifiedAt; + private LocalDateTime modifiedAt; @PrePersist public void prePersist() { - this.createdAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); + String formattedDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); + this.createdAt = LocalDateTime.parse(formattedDate,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); this.modifiedAt = this.createdAt; } @PreUpdate public void onUpdate() { - this.modifiedAt = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); + String formattedDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); + this.modifiedAt = LocalDateTime.parse(formattedDate,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); } } diff --git a/src/main/java/com/kimgreen/backend/domain/notification/dto/NotificationResponseDto.java b/src/main/java/com/kimgreen/backend/domain/notification/dto/NotificationResponseDto.java index f6da5a2..7a43636 100644 --- a/src/main/java/com/kimgreen/backend/domain/notification/dto/NotificationResponseDto.java +++ b/src/main/java/com/kimgreen/backend/domain/notification/dto/NotificationResponseDto.java @@ -13,7 +13,7 @@ @Getter public class NotificationResponseDto { private Long postId; - private String createdAt; + private LocalDateTime createdAt; private String content; public static NotificationResponseDto getDto(Notification notification) {