10

I am using Thymeleaf #dates.format() function for format date in view layer. I create one internatinalization properties file for pic the date format. i am using #dates.format(date, (#{app.dateformat})) function like this. but Thymeleaf throw an parse exception. Because thymeleaf now resolve the app.dateformat. How i use date format internationalization way in thymeleaf. Following is an exception:

org.springframework.expression.spel.SpelParseException: EL1043E:(pos 37): Unexpected token. Expected 'identifier' but was 'lcurly({)'

1 Answer 1

17

You should use this syntax instead :

${#dates.format(date, #messages.msg('app.dateformat'))}

#messages : utility methods for obtaining externalized messages inside variables expressions, in the same way as they would be obtained using #{...} syntax.

Source

Sign up to request clarification or add additional context in comments.

2 Comments

can I used this sintax in version 2.1 ?
works for me in this case: th:classappend="${#httpServletRequest.requestURI.endsWith(#messages.msg('link.app.public.legal.about-us'))}

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.