Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,I hava some confusions when using @DateTimeFormat.My understanding about @DateTimeFormat is that is's used to validate and convert the string date in the jsp page to the some entity's field whose format is specified by the @DateTimeFormate(eg:yyyy/MM/dd).
Suppose that I hava a contact entity,I get the contact's info and displays it in the edit form,I find that,when I use
HTML
<form:input path="birthDate" id="birthDate" />
,its html output will be formatted using the format specified in the @DateTimeFormat,while using the normal way,such as
HTML
<p>${contact.birthDate}</p>
,it just output it directly using the date from db.
My questions are:
1.What's @DateTimeFormat's effect? Can it really not only format the string date(in jsp page) to the entity's field but also format the entity's field from db and displays it in the jsp page using the specified format?If so,how spring handle this annotation? Does other formatter annotation work so?
2.Why it just work for the
HTML
<form>
tag situation?
3.And further introductions about this will be appreciated.

Thanks.
Posted
Updated 10-Mar-15 6:07am
v2
Comments
Maciej Los 10-Mar-15 15:25pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900