@Getter
@MappedSuperclass //멤버 변수가 컬럼이 되도록합니다.
@EntityListeners(AuditingEntityListener.class)//변경 되었을때 자동으로 기록합니다.
public class Timestamped implements Serializable {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'작성시간'HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@CreatedDate//최소 생성시점
private LocalDateTime createdDate;
private String createdDateString;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'작성시간'HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@LastModifiedDate//마지막 변경시점
private LocalDateTime modifiedDate;
@PrePersist
public void onPrePersist(){
this.createdDateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
}
}
//자바 역직렬화 문제 해결 패키지
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'com.fasterxml.jackson.core:jackson-databind'
private String createdDateString;
.....
@PrePersist // 영속성컨텍스트가 일어나기전에 시행함
public void onPrePersist(){
this.createdDateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
}
this.createdDate = faq.getCreatedDateString();
private final LocalDateTime createdDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'작성시간'HH:mm:ss")
"작성시간" 부분이 포맷 문자열 안에서 문자열 리터럴로 사용되고 있습니다. 따라서 실제로는 "작성시간"이라는 문자열이 포함되어 있는 형태로 직렬화됩니다.
따라서 결과로 출력되는 "createdDate" : "2023-06-25T20:12:17.392801"는 "yyyy-MM-dd'작성시간'HH:mm:ss" 패턴에 따라 포맷팅된 문자열입니다.
@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm")
private final LocalDateTime createdDate;
this.createdDate = faq.getCreatedDate();
또는 TimeStamped.class 를 serialize 상속하지 않은채로 해당 필드에 형식 지정해줘도 된다.
@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class TimeStamped {
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
@CreatedDate
private LocalDateTime createdDate;
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
@LastModifiedDate
private LocalDateTime modifiedDate;
}
https://melonplaymods.com/2023/06/11/fnaf-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/howitzer-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/zeta-ultraman-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/rare-wubbox-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/train-mod-for-melon-playground-4/
https://melonplaymods.com/2023/06/10/dash-attack-titan-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/bendy-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/pack-of-robots-21-characters-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/ben-10-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/ninja-mod-for-melon-playground-2/
https://melonplaymods.com/2023/06/11/kv-2-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/doors-library-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/banana-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/helicopter-mi-26-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/ch53k-transport-helicopter-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/pack-for-vegetables-and-fruits-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/ww2-weapon-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/people-sandbox35-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/mechanical-spider-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/roblox-doors-theme-pack-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/submarine-dmitry-donskoy-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/room-furniture-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/russian-german-and-ukrainian-flags-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/e-girl-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/piggynpc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/eddsworld-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/ersimov-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/megatron-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/pak-organs-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/raiden-from-metal-gear-solid-2npc-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/katakuri-with-trident-mochi-skill-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/naruto-akatsuki-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/bendy-ax-bendys-ax-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/all-terrain-vehicle-caucasian-2-mod-for-melon-playground/
https://melonplaymods.com/2023/06/10/functional-chainsawman-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/german-soldiers-from-wwiisvproplayer-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/godzilla-mod-for-melon-playground-3/
https://melonplaymods.com/2023/06/11/terraria-melee-pack-v0-3-melee-weapons-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/piggy-book-1-piggy-book-1-characters-mod-for-melon-playground/
https://melonplaymods.com/2023/06/11/desk-lamp-mod-for-melon-playground-2/
므집니다!!!