java - spring mvc date format with form:input -
i have hibernate entity , bean:
@entity public class generalobservation { @datetimeformat(pattern = "dd/mm/yyyy") date date; @column public date getdate() { return date; } public void setdate(date date) { this.date = date; } }
also have
@initbinder protected void initbinder(webdatabinder binder) { simpledateformat dateformat = new simpledateformat("dd/mm/yyyy"); binder.registercustomeditor(date.class, new customdateeditor( dateformat, false)); }
and
form:input id = "datepicker" name="date" itemlabel="date" path="newobservation.date"
when go url see:
how can force have mm/dd/yyyy format? thanx
you can use fmt:formatdate jstl tag:
<fmt:formatdate value="${yourobject.date}" var="datestring" pattern="dd/mm/yyyy" /> <form:input path="date" value="${datestring} .. />
Comments
Post a Comment