Take the 2-minute tour ×

I have a Spring Roo mvc project going with a model called WorkOrder. I used the Roo shell to generate two finders for this model: findWorkOrdersByDateCompletedEquals and findWorkOrdersByDateCompletedBetween.

Problem: when I search using the findWorkOrdersByDateCompletedBetween, the minDateCompleted and maxDateCompleted parameters in the url are in the wrong format (the S- format)


Here is the error from the debug log:

Failed to convert from type java.lang.String to type 
@org.springframework.format.annotation.DateTimeFormat java.util.Date for value '2012-05-15';

The funny thing is that the findWorkOrdersByDateCompletedEquals works just fine, and generates a url like this:


What determines how these URLs get generated? The code is virtually identical between the two finders, why would they generate dates in different formats?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I found the real problem, it looks like it's a bug with Spring roo. There is a method in the controller .aj file that Roo didn't update:

void addDateTimeFormatPatterns(Model uiModel) {
    uiModel.addAttribute("workOrder_datecompleted_date_format", DateTimeFormat.patternForStyle("M-", LocaleContextHolder.getLocale()));
    uiModel.addAttribute("workOrder_maxdatecompleted_date_format", DateTimeFormat.patternForStyle("M-", LocaleContextHolder.getLocale()));
    uiModel.addAttribute("workOrder_mindatecompleted_date_format", DateTimeFormat.patternForStyle("M-", LocaleContextHolder.getLocale()));

Roo automatically put the "workOrder_datecompleted_date_format" attribute there, but I had to push in the method and add the maxdatecompleted and mindatecompleted attributes myself.

share|improve this answer
add comment

I've found like a dirty way to solve it.. :P

just change the dateTimePatern attribute of your fields that you have in

to the one that you have in

in my case it was something like
field:datetime dateTimePattern="${tramite_maxfecha_date_format}" [...]

and I changed it to
field:datetime dateTimePattern="${tramite_fecha_date_format}"

share|improve this answer
Thanks, that gave me enough to figure out the bug :) –  MattL May 30 '12 at 20:41
add comment

Your Answer


