Sort table on a date column, which has converted String values

I have a table, which has a date column. I convert the date to dd MMM YYYY HH:MM:SS format ( for ex: 23 JAN 2012 12:45:32) before printing on the table. When i sort the table on this date column. It prints the 13 Dec 2012 before the 22 Nov 2012, which is not an ascending order. It is sorting on the converted string values not the actual date values, which is understood. I want to sort the table based on Month ,date, year values ( like MM/dd/YYYY/) format. So November dates should come first and then the December ones. Similarly the date also should be ascending…Nov 9 should come before Nov 14 etc…

I have tried creating two date columns,one with MM/dd/YYYY/ and one with dd MMM YYYY format, set the default sorrting on the MM/dd/YYYY column and collpase it. But when I click the dd MMM YYYY column, the sorting is gone.

Any idea how to sort a table on date column, which has string reprsentation of DATE values…


Have you tried to put in the java.util.Date object instead of string? Then you can

protected String formatPropertyValue(Object rowId, Object colId, Property property)

of the Table class to format the date as you need it. I think sorting should work in this case because of the compare method of Date class but I haven’t tried.

HTH, Steffen

Thanks. I have tried. The issue was having the date column’s type as Object instead of Date. The column type is declared as Object to allow all types of values for columns. So i have to add ItemSorter and implement it’s compare() method for date values and use “formatPropertyValue()” method to change the date format…
It works fine now.

Check this out…

Thanks again.