Reputation: 3871
I have created a helper to parse time froma webservice and output inanother format using @DateTimeFormat. However in my jsp view this is not formatted. Am I using this wrong?
@Component
public class DateParserHelper {
@DateTimeFormat(style="F-")
public Date getFormattedDate() {
return formattedDate;
}
public void setFormattedDate(Date formattedDate) {
this.formattedDate = formattedDate;
}
public Date formattedDate;
public void setDate(String date) throws ParseException {
DateFormatter dateFormatter = new DateFormatter("y-M-d");
setFormattedDate( dateFormatter.parse(date, UK));
}
}
Upvotes: 0
Views: 3194
Reputation: 71
If you are using JSTL in your jsp, you could use formatDate to format your date :
<fmt:formatDate value="${yourDate}" pattern="dd/MM/yyyy" />
Upvotes: 1
Reputation: 4693
Try SimpleDateFormat
String pattern = "MM/dd/yyyy";
...
public void setDate(String date) {
SimpleDateFormat format = new SimpleDateFormat(pattern);
setFormattedDate(format.parse(date));
}
Upvotes: 0