From d8913462c2d6fa793613131952afc85591ec3c61 Mon Sep 17 00:00:00 2001 From: Benedetta-fabbri Date: Thu, 16 Jan 2025 15:08:04 +0100 Subject: [PATCH] fix test --- .../pagopa/pu/organization/model/BaseEntity.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/BaseEntity.java b/src/main/java/it/gov/pagopa/pu/organization/model/BaseEntity.java index 607d4f0..588875f 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/BaseEntity.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/BaseEntity.java @@ -1,6 +1,9 @@ package it.gov.pagopa.pu.organization.model; -import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; import jakarta.persistence.MappedSuperclass; @@ -12,6 +15,7 @@ import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.time.LocalDateTime; @@ -25,10 +29,16 @@ public abstract class BaseEntity implements Serializable { @Column(updatable = false) @CreatedDate - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ") + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + //@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ") private LocalDateTime creationDate; @LastModifiedDate - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ") + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + //@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ") private LocalDateTime updateDate; @LastModifiedBy private String updateOperatorExternalId;