방법 1 (옛날 방법)

Controller

 

@InitBinder
public void initBinder(WebDataBinder binder) {

SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd");
binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(df,false));


}

 

 

 

@Data
public class TodoDTO {


private String title;
private Date dueDate;


}

 

@GetMapping("/ex03")

public String ex03(TodoDTO todo) {

log.info("todo: " + todo);



}

 

방법 2 (최근 방법 Spring 에서 지원)

 

@Data
public class TodoDTO {


private String title;

@DateTimeFormat(pattern="yyy/MM/dd")
private Date dueDate;


}

+ Recent posts