I have a entity class and it has java.util.Date type property. And when I pass "path" param to my input as defult it shows me like this :
But I want to change pattern of it. Also it must display existing Date value of selected owner object.
I tried to use fmt:formatDate but it doesnt work :/
<div class="form-group">
<label class="col-sm-3 control-label"><spring:message code="label.name" /><span class="text-danger">*</span></label>
<div class="col-sm-8">
<fmt:formatDate value="${owner.installDate}" var="installDate" pattern="dd/MM/yyyy" />
<form:input type="date" path="installDate" value="${installDate}" class="form-control" placeholder="Yuklenme tarixini yazin....." required="true" />
<form:errors path="installDate" cssClass="error"></form:errors>
</div>
Just make sure you have following covered in your code.
The tag library is added in your jsp
Also make sure owner.installDate
returns java.util.Date not String
Add type="date"
to your code
<fmt:formatDate value="${owner.installDate}" var="installDate" type="date" pattern="dd/MM/yyyy" />
Parse the date string first to java.util.Date as below
<fmt:parseDate value="${owner.installDate}" pattern="yyyy-MM-dd HH:mm:ss" var="myDate"/>
<fmt:formatDate value="${myDate}" var="installDate" type="date" pattern="dd/MM/yyyy" />