Skip to content

Commit 0960ce0

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

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
77
zipStorePath=wrapper/dists
8+
org.gradle.jvmargs=-Dtime.nano-precision=6

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)