I have a JTable and have added sorting. Now the JTable has 5 columns and the 2nd column in a date field converted to DD/MM/YYYY and displayed in a JTextField in the cell.
When I sort it sorts as string and I the dates get mixed up, how do I change the behaviour of sorting for that particular column?
eg. after sorting in ASC order, I get this:
01/02/2012
01/03/2011
01/04/2011
01/05/2011
01/06/2011
01/07/2011
01/08/2011
01/09/2011
01/10/2011
01/12/2011
Which is wrong, and I should be getting the result like
01/03/2011
01/04/2011
01/05/2011
01/06/2011
01/07/2011
01/08/2011
01/09/2011
01/10/2011
01/12/2011
01/02/2012
My code now looks like this for sorting
List<SortKey> sortKeys = new ArrayList<SortKey>();
sortKeys.add(new SortKey(2, SortOrder.ASCENDING));
table.getRowSorter().setSortKeys(sortKeys);
What should I change for that specific column only?