GOAL:
Set 4-digit Year (e.g. 1999) field to LocalDate Controller attribute. How do I set the input::1999 to DateTime object in Spring MVC?
JSP:
<form:form action="${url}" method="POST" commandName="form">
<form:input id="year" path="works[0].startDate.year"/>
</form:form>
SETTER: DateTime updated with 4-digit year
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class WorkRequest {
@DateTimeFormat(pattern = "MM/dd/yyyy")
@XmlElement(name = "start_date")
public DateTime startDate;
public void setStartDate(DateTime startDate){
//update 4-digit only
}
}
Aucun commentaire:
Enregistrer un commentaire