繁体   English   中英

Spring Mvc错误的日期格式

[英]Spring Mvc Wrong Date Format

我尝试使用粘合剂这样的Spring MVC日期格式化程序

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

但我需要格式为"dd-MM-YYYY" 如果我使用这种格式的mysql保存错误的日期

表格数据: 07-12-1980
MySql数据: 0013-05-02

在您的POJO中,尝试将其添加到日期对象中。

@DateTimeFormat(pattern = "dd/MM/yyyy")
private Date dob;

资料来源: 这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM