I have a problem with the json serialization of ZonedDateTime
. When converted to json it produces an enormous object and I don't want all that data to be transfered every time. So i tried to format it to ISO but it doesn't work. How can i get it to format?
Here is my Entity Class:
@MappedSuperclass
public abstract class AuditBase {
@Id
@GeneratedValue
private Long id;
@CreatedDate
private ZonedDateTime createdDate;
@LastModifiedDate
private ZonedDateTime lastModifiedDate;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
public ZonedDateTime getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(ZonedDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
public ZonedDateTime getCreatedDate() {
return createdDate;
}
public void setCreatedDate(ZonedDateTime createdDate) {
this.createdDate = createdDate;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@PrePersist
public void prePersist() {
this.createdDate = ZonedDateTime.now();
this.lastModifiedDate = ZonedDateTime.now();
}
@PreUpdate
public void preUpdate() {
this.lastModifiedDate = ZonedDateTime.now();
}
}