Skip to content

Commit 8c45739

Browse files
committed
chore: createAt과 updateAt의 나노초 길이 고정
1 parent ae8ff39 commit 8c45739

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/example/solidconnection/entity/common/BaseEntity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.time.ZoneId;
1313
import java.time.ZonedDateTime;
1414

15+
import static java.time.temporal.ChronoUnit.MICROS;
16+
1517
@MappedSuperclass
1618
@EntityListeners(AuditingEntityListener.class)
1719
@Getter
@@ -24,12 +26,12 @@ public abstract class BaseEntity {
2426

2527
@PrePersist
2628
public void onPrePersist() {
27-
this.createdAt = ZonedDateTime.now(ZoneId.of("UTC"));
29+
this.createdAt = ZonedDateTime.now(ZoneId.of("UTC")).truncatedTo(MICROS); // 나노초 6자리 까지만 저장
2830
this.updatedAt = this.createdAt;
2931
}
3032

3133
@PreUpdate
3234
public void onPreUpdate() {
33-
this.updatedAt = ZonedDateTime.now(ZoneId.of("UTC"));
35+
this.updatedAt = ZonedDateTime.now(ZoneId.of("UTC")).truncatedTo(MICROS);
3436
}
3537
}

0 commit comments

Comments
 (0)