Formatting date in Thymeleaf

前端 未结 5 1264
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 23:22

I\'m brand new to Java/Spring/Thymeleaf so please bear with my current level of understanding. I did review this similar question, but wasn\'t able to solve my problem.

相关标签:
5条回答
  • 2020-12-05 00:02

    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

    0 讨论(0)
  • 2020-12-05 00:09

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

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

    0 讨论(0)
  • 2020-12-05 00:12

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

    You can use:

     th:text="${#temporals.format(notice.date,'dd-MM-yyyy')}
    
    0 讨论(0)
  • 2020-12-05 00:15

    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

    0 讨论(0)
  • 2020-12-05 00:22

    you should use Thymeleaf formatting milliseconds

    <td th:text="${#dates.format(new java.util.Date(transaction.documentDate), 'dd-MMM-yy')}"></td>
    
    0 讨论(0)
提交回复
热议问题