我是 Java/Spring/Thymeleaf 的新手,所以请理解我目前的理解水平。我确实审查 了这个类似的问题,但无法解决我的问题。
我正在尝试获取简化日期而不是长日期格式。
// DateTimeFormat annotation on the method that's calling the DB to get date.
@DateTimeFormat(pattern="dd-MMM-YYYY")
public Date getReleaseDate() {
return releaseDate;
}
html:
<table>
<tr th:each="sprint : ${sprints}">
<td th:text="${sprint.name}"></td>
<td th:text="${sprint.releaseDate}"></td>
</tr>
</table>
电流输出
sprint1 2016-10-04 14:10:42.183
原文由 adam.shaleen 发布,翻译遵循 CC BY-SA 4.0 许可协议
Bean 验证无关紧要,您应该使用 Thymeleaf 格式:
还要确保您的
releaseDate
属性是java.util.Date
。输出将是这样的:
04-Oct-2016