Skip to content

Commit

Permalink
SHIBUI-2249
Browse files Browse the repository at this point in the history
Changing datetime precision to 6 from 9
  • Loading branch information
chasegawa committed Nov 2, 2021
1 parent 0bfaa29 commit f11accd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public abstract class AbstractAuditable implements Auditable {

@CreationTimestamp
@CreatedDate
@Column(nullable = false, updatable = false, columnDefinition = "DATETIME(9)")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS")
@Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
private LocalDateTime createdDate;

@UpdateTimestamp
@LastModifiedDate
@Column(nullable = false, columnDefinition = "DATETIME(9)")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS")
@Column(nullable = false, columnDefinition = "DATETIME(6)")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
private LocalDateTime modifiedDate;

@Column(name = "created_by")
Expand Down Expand Up @@ -132,4 +132,4 @@ private static ZonedDateTime toZonedDateTime(LocalDateTime localDateTime) {
.atOffset(ZoneOffset.UTC)
.toZonedDateTime();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class BaseDataJpaTestConfiguration {
@Bean
ObjectMapper objectMapper() {
JavaTimeModule module = new JavaTimeModule()
LocalDateTimeDeserializer localDateTimeDeserializer = new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS"))
LocalDateTimeDeserializer localDateTimeDeserializer = new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS"))
module.addDeserializer(LocalDateTime.class, localDateTimeDeserializer)
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().modules(module).featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build()
mapper.enable(SerializationFeature.INDENT_OUTPUT)
Expand Down

0 comments on commit f11accd

Please sign in to comment.