I'm having issues with using the @DateTimeFormat Spring annotation. I've been researching a bit about it today, but for some reason I just can't get it to work.
@DateTimeFormat(pattern="MM/dd/yyyy")
@Column(name="my_date")
private Date myDate;
public Date getMyDate() {
return this.myDate;
}
public void setMyDate(Date myDate) {
this.myDate = myDate;
}
Right now the code is displaying the date and time as yyyy-MM-dd HH:mm:ss.S (i.e. 2012-01-11 00:00:00.0)
I read that you need Joda-Time added to your class path and I've done that. Am I missing something?
You need to enable the processing of those annotations. The easiest way is with mvc schema...
Joda Time is not required for formatting. @DateTimeFormat can be used on long, Date and Calendar fields. If you want to use it on Joda Time fields, you need to have 1.3 or higher on your classpath