Reputation: 1621
LocalDateTime as application.property
My application.properties looks like this:
date.format='dd-MM-yyyy'
<p th:text="${#temporals.format(localDateTime, 'dd-MM-yyyy')}"></p>
How to replace 'dd-MM-yyyy' wit my property?
Upvotes: 1
Views: 849
Reputation: 14731
You can get property from @environment
.
@environment.getProperty('date.format')
But this will not solve it for you, next step is to preprocess this expression with __
notation
<p th:text="${#temporals.format(localDateTime, __${@environment.getProperty('date.format')}__)}">
But even this version will not work, because you format needs quotes
format(localDateTime, 'dd-MM-yyyy')
and you are passing
format(localDateTime, dd-MM-yyyy)
so the final working version
should look like this:
<p th:text="${#temporals.format(localDateTime, __${''''[email protected]('date.format')+''''}__)}">
So as you can see it is much easier to just pass format from controller)
Upvotes: 1