spring mvc 后台只接收String类型,所以需要对日期类型处理

一、只需要在方法中加入

@InitBinder  
protected  void initBinder(WebDataBinder binder) {  
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");  
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));  
}  

方法就可以

二、注解方式:   需要joda 包

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")  //取日期时使用  
@DateTimeFormat(pattern = "yyyy-MM-dd")//存日期时使用  
private Date startTime;  
原文地址:https://www.cnblogs.com/zuge/p/6202640.html