弹簧 mvc 日期格式与表单:输入
2022-09-02 09:35:29
我有休眠实体和一个豆子:
@Entity
public class GeneralObservation {
@DateTimeFormat(pattern = "dd/MM/yyyy")
Date date;
@Column
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
我也有
@InitBinder
protected void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, false));
}
和
form:input
id = "datepicker"
name="date"
itemLabel="date"
path="newObservation.date"
当我转到我的网址时,我看到:
如何强制它具有 mm/DD/yyyy 格式?感恩节