Spring boot ThymeLeaf传递时间戳值
我试图以“Spring boot ThymeLeaf传递时间戳值,spring-boot,thymeleaf,Spring Boot,Thymeleaf,我试图以“2013-12-31 12:00:00.000007”的格式传递时间戳值,我的java模型类将此属性作为“java.sql.timestamp” 我尝试使用以下html代码传递,但它不接受字段中输入的值,而是接受null值 <td><input id="updateDateTime" name="updateDateTime" type="text" th:field="*{updateDateTi
2013-12-31 12:00:00.000007
”的格式传递时间戳值,我的java模型类将此属性作为“java.sql.timestamp
”
我尝试使用以下html代码传递,但它不接受字段中输入的值,而是接受null值
<td><input id="updateDateTime" name="updateDateTime" type="text" th:field="*{updateDateTime}"/></td>
您是否测试了您是否可能得到一个
ParseException
?
@InitBinder
public void binder(WebDataBinder binder) {
binder.registerCustomEditor(Timestamp.class,
new PropertyEditorSupport() {
public void setAsText(String value) {
try {
Date parsedDate = new SimpleDateFormat("MM/dd/YYYY HH:mm:ss.SSSSSS").parse(value);
setValue(new Timestamp(parsedDate.getTime()));
} catch (ParseException e) {
setValue(null);
}
}
});
}