Jestem nowy w Java/Spring/Thymeleaf, więc proszę o zachowanie mojego obecnego poziomu zrozumienia. Zrobiłem recenzję this similar question, ale nie udało mi się rozwiązać mojego problemu.Formatowanie daty w Thymeleaf
Próbuję uzyskać datę uproszczoną zamiast długiego formatu daty.
// 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>
Wyjście prądowe
sprint1 2016-10-04 14:10:42.183
będę po prostu zostawić to tutaj: Jeśli jesteś używając LocalDate lub LocalDateTime użyj "temporals" zamiast "dat" w Thymeleaf –