# 스프링 MVC는 세 가지 방법의 형식 매개 변수 변환을 바인딩 : ## 1 개 엔티티 클래스가 포맷 날짜 주석을 추가했다. @DateTimeFormat (패턴 = " YYYY MM은-DD-HH : mm " ) 개인 날짜입니다 creationTime과를, ## 2 속성을. 편집기 spring3.1 전에 @InitBinder 의해 제어기 클래스 생성 / * * 코드 결합 컨트롤러 레이어의 데이터 * 첨가 한 조각 * @param WebDataBinder * / @InitBinder 공개 무효 예외 {를 슬로우 initBinder (WebDataBinder WebDataBinder)의 SimpleDateFormat의 SimpleDateFormat는 = 새로운 새로운 SimpleDateFormat의 ( " YYYY-MM은-DD HH : MM " ); (simpleDateFormat.setLenient false로 ) webDataBinder.registerCustomEditor (날짜. 클래스 , 새로운 새로운 CustomDateEditor가 (SimpleDateFormat에, true로 )); } 참고 : 사용자 정의 형식 변환기가 PropertyEditorSupport 상속의 PropertyEditor 인터페이스 또는 클래스를 구현해야합니다 propertyEditorSupport (구현의 PropertyEditor)를 확장하는 클래스를 작성 { 공공 무효 setAsText는 (문자열 텍스트)에서이 { SimpleDateFormat의 SimpleDateFormat의이 = 새 새 SimpleDateFormat의을 ( " YYYY의 HH - MM-DD : mm " ); 날짜 날짜 = simpleDateFormat.parse (텍스트) 은이를 .setValue (DATE)를; } 공공 문자열 getAsTest () { 날짜 날짜 = (날짜) 은이 .getValue (); 반환 은이 .dateFormat.format (날짜); } } ## . 3 . 형식 변환기 변환기 글로벌 형식 변환 참조 사전 클래스 코드