I have an Integer
for month in the DTO
class. While displaying on thymeleaf template, I just want it to be month name in string like 'January' for integer value 0, and so on. I checked #dates
but could not find one.
-
1I don't think there are any good ways to do this in Thymeleaf. If you could pass the Date rather than an integer it would be easy... alternatively, a method on your DTO that returns the month as a string maybe?– MetroidsCommented Sep 5 at 1:33
Add a comment
|
1 Answer
Shall use java.time.Month
enumeration as below and convert case as you want. In this case I'm getting initcapped month name like January
.
th:text=${#strings.capitalize(#strings.toLowerCase(T(java.time.Month).of(dto.monthField+1).name))}