특징
형식
public class EventDto{
@DateTimeFormat(pattern = "yyy-MM-dd")
private LocalDate eventDate; //"2024-01-15"
@DateTimeFormat(pattern = "yyyy/MM/dd")
private LocalDate startDate; // "2024/01/15"
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime eventDateTime; //"2024-01-15 14:30"
@DateTimeFormat(pattern = "HH:mm:ss")
private LocalTime eventTime //"14:30:25"
}
형식
iso 속성
import org.springframework.format.annotation.DateTimeFormat.ISO;
public class IsoDateDto{
@DateTimeFormat(iso = ISO.DATE)
private LocalDate date; // "2024-01-15"
@DataTimeFormat(iso = ISO.TIME)
private LocalTime time; // "14:30:25"
@DateTimeFormat(iso = ISO.DATE_TIME)
private LocalDateTime dateTime; // "2024-01-15T14:30:25"
@DateTimeFormat(iso = ISO.NONE)
private LocalDate customDate; // 기본값, 패턴 직접 지정
}
장점
단점
LocalDate
LocalDateTime