I have a JSP form element that looks like:
<form:input path="foo" id="bar" value="${myObject.myDate}" class="fizz buzz bang"/>
and I want to format this date so that it initially appears like: yyyy/mm/dd
I know I can format a date in JSP easily like this:
<fmt:formatDate value="${blah.bla}" pattern="MM-dd-yyyy" />
but how can I combine the two?
When I do:
<form:input path="foo" id="bar" value=" <fmt:formatDate value="${myObject.myDate}" pattern="MM-dd-yyyy" /> " class="fizz buzz bang"/>
I get exceptions on the line like:
org.apache.jasper.JasperException: Unterminated form:input tag
What am I doing wrong?
You cannot directly use <fmt:formatDate> inside the form input tag. You can format it and assign the variable to value of form input.
<fmt:formatDate value="${blah.bla}" pattern="dd/MM/yyyy" var="myDate" />
<form:input path="foo" id="bar" value="${myDate} />
Hope this helps.
Source
Spring mvc date format with form:input
How to make fmt:formatDate work for form:input
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With