0

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.

1
  • 1
    I 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?
    – Metroids
    Commented Sep 5 at 1:33

1 Answer 1

0

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))}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.