I found the solution to this problem,
It was a detail and pretty obviuos, but well...i am learning.
If someone might met the same problem:
Do not forget to add the following line in the controller method that displays the form for the first time:
Code:
addDateTimeFormatPattern(model);
This line adds a valid format to the date before you submit the form, so if it is missing the date wont be formatted by the time you save the form.
Here is the code of the controller:
Code:
@RequestMapping(method = RequestMethod.GET)
public String list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model model) {
if (page != null || size != null) {
int sizeNo = size == null ? 10 : size.intValue();
//model.addAttribute("profiles", Device.findDeviceEntries(page == null ? 0 : (page.intValue() - 1) * sizeNo, sizeNo));
model.addAttribute("profiles", Profile.findProfileEntries(page == null ? 0 : (page.intValue() - 1) * sizeNo, sizeNo));
//float nrOfPages = (float) Device.countDevices() / sizeNo;
float nrOfPages = (float) Profile.countProfiles() / sizeNo;
model.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
} else {
model.addAttribute("profiles", Profile.findAllProfiles());
}
model.addAttribute("profile", new Profile());
addDateTimeFormatPatterns(model);
return "personProfiles";
}
Happy programming everyone.