How to change <fmt:formatDate>
pattern dynamically? I have two patterns for two locales. Also I have the property file for each locale with the date.format
key, somewhere its value is MM/dd/YYYY
, somewhere DD/MM/YYYY
, and so on. In the JSP I have the following tag:
<fmt:formatDate value="${news.creationDate}" pattern="<tag:resource key="date.format"/>"
Where <tag:resource>
is my own tag, which gives resources from a property file.
You can't nest tags, but you can assign the value to a variable and pass that along.
<c:set var="dateFormat"><tag:resource key="date.format" /></c:set>
<fmt:formatDate value="${news.creationDate}" pattern="${dateFormat}" />