Date will be processed by the #dates utility.
New LocalDateTime , LocalDate will be processed by the #temporals utility.
Set the format :
<p th:text="${#dates.format(standardDate, 'dd-MM-yyyy HH:mm')}"></p> <p th:text="${#temporals.format(localDateTime, 'dd-MM-yyyy HH:mm')}"></p> <p th:text="${#temporals.format(localDate, 'MM-yyyy')}"></p>
Where you should send it to view as follows:
model.addAttribute("standardDate", new Date()); model.addAttribute("localDateTime", LocalDateTime.now()); model.addAttribute("localDate", LocalDate.now());
LocalDate formatting is LocalDate possible if we specify only certain date fields, skipping time fields.
Output Result :
24-05-2019 21:57 24-05-2019 21:57 24-05-2019
nazar_art
source share