方法一
在返回的实体的属性中加上注解
// 创建时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
方法二
在Controller中注解一个@InitBinder,使用@ResponseBody时会将实体中的属性为Data类型的转换成JSON格式的日期
private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd");
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Date.class, new CustomDateEditor(DATEFORMAT, true));
}