The problem: Display tag sorts all values as Strings which means that date values are sorted incorrectly by displaytag. One way to do this is write your own decorator class which implements a sort for dates and use this decorator on your field.

A quick and easy way to sort date items correctly without having to write your own decorator class is to: change the date format to yyyy/mm/dd This is a date display which correctly sorts in string representation. It is that easy.

If you want sort your list by any colum by default you can specify the column index of the column you want to sort in the defaultsort=”" attribute of the table tag. The default order can be set using the defaultorder attribute: the default value is ascending, you can set it to descending to reverse the order. So, to sort by default your date column, set defaultsort equal to the column index of the date column (remember 0 based indexing) and then set defaultorder=”decending” so you have most recent dates first.

del.icio.us:An easy way to correctly sort date fields in Java displaytag digg:An easy way to correctly sort date fields in Java displaytag spurl:An easy way to correctly sort date fields in Java displaytag wists:An easy way to correctly sort date fields in Java displaytag simpy:An easy way to correctly sort date fields in Java displaytag newsvine:An easy way to correctly sort date fields in Java displaytag blinklist:An easy way to correctly sort date fields in Java displaytag furl:An easy way to correctly sort date fields in Java displaytag reddit:An easy way to correctly sort date fields in Java displaytag fark:An easy way to correctly sort date fields in Java displaytag blogmarks:An easy way to correctly sort date fields in Java displaytag Y!:An easy way to correctly sort date fields in Java displaytag smarking:An easy way to correctly sort date fields in Java displaytag magnolia:An easy way to correctly sort date fields in Java displaytag segnalo:An easy way to correctly sort date fields in Java displaytag