我正在使用下面的Customer实体来映射Date字段
@Temporal(TemporalType.DATE)
@Column(name = "birthdate")
@DateTimeFormat(pattern = "dd-MM-yyyy")
private Date birthDate;但是BirthDate仍然是以yyyy-MM-dd格式保存的。我尝试过使用birthDate为字段DateFormat设置setter方法,但响应仍然相同。
数据库为Mysql,列为Date类型。我希望以dd-MM-yyyy格式设置值。
发布于 2018-06-16 14:24:52
据我所知,从以前的项目,这是给定的日期格式在MySQL,不能改变这么直接。我将在映射中设置与数据库(YYYY-MM-DD)相同的日期模式,并在以后的使用中重新格式化它。
https://stackoverflow.com/questions/50888699
复制相似问题