Sort a JTable with date in a column

387 views Asked by At

I have a JTable that has a column with a date in this format: "Mon Nov 19 18:03:23 WET 2018". I want to sort my rows by the date. I've tried using TableRowSorter but I can't sort it by the date. Is that any way?

TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel> (tableModel);
    timeline.setRowSorter(sorter);

I add the content to the rows like this:

tableModel.addRow(new Object[]{"Twitter", t.getCreatedAt().toString(), t.getText()});

Thanks :)

0

There are 0 answers