Spring Boot
[SpringBoot] DateTime Format
SO-BBANG
2021. 6. 11. 15:05
- Response (서버 -> 클라이언트) 로 전달할 때에는 @JsonFormat 을 사용,
// vo ( Server -> Client )
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime registerDate;
※주의 : 엑셀 출력시엔 JsonFormat이 안먹기 때문에 (client에 보낼때 json으로 컨버팅할경우) 그런 경우는 String으로 처리해야함
- Request(클라이언트 -> 서버)로 전달할 때는 @DateTimeFormat 을 사용한다.
@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") // 공백 대신 T를 넣어주거나 (선호)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 공백으로 보내도 무관하다.
@Builder.Default
private LocalDateTime endDate = LocalDateTime.now();