Trying to populate and formate a date value inside an INPUT text field. What am I doing wrong here?
<spring:bind path="salesData.weekEndDate">
<input type="text" name="${status.expression}"
value="${fmt:formateDate pattern='MM/mm/YYYY' status.value}"
/>
The JSTL
fmttaglib exists of<fmt:xxx>tags, not${fmt:xxx}functions.Fix it accordingly:
(note that days are to be represented as
dd, notmmand that years are to be represented asyyyy, notYYYY, see alsoSimpleDateFormatjavadoc for all valid patterns)If your IDE jerks about the nested tags (which should run perfectly fine however) or you get itch from it, make use of the
varattribute so that your HTML/XML ends up well formed.If you really like to have a
${fmt:formatDate()}function, you’d have to homegrow it yourself. You can find a kickoff example in this answer.Update as turns out per comments, the
${status.value}is actually aStringin the formatyyyy-MM-dd. If fixing it to be a fullworthyDateis not an option, then you would need to parse it into aDatefirst with help of<fmt:parseDate>before feeding it to<fmt:formatDate>.