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:

my form

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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -