Skip to content

Commit

Permalink
[fix] fix AuditEntity : String to LocalDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
gol2580 committed Jan 17, 2024
1 parent dcd45a1 commit 0e274a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/kimgreen/backend/domain/AuditEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0e274a1

Please sign in to comment.