Formatting date in Thymeleaf

故事扮演 提交于 2019-11-30 01:17:14

Bean validation doesn't matter, you should use Thymeleaf formatting:

<td th:text="${#dates.format(sprint.releaseDate, 'dd-MMM-yyyy')}"></td>

Also make sure your releaseDate property is java.util.Date.

Output will be like: 04-Oct-2016

If you want to use converters in th:text attributes, you have to use double-bracket syntax.

<td th:text="${{sprint.releaseDate}}"></td>

(They are automatically applied to th:field attributes)

http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#double-bracket-syntax

If you want show por example = 20-11-2017

You can use:

 th:text="${#temporals.format(notice.date,'dd-MM-yyyy')}

you should use Thymeleaf formatting milliseconds

<td th:text="${#dates.format(new java.util.Date(transaction.documentDate), 'dd-MMM-yy')}"></td>

th:text="${#calendars.format(store.someDate(),'dd MMMM yyyy')}"

API : https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#calendars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!