Sorry for asking basic question once again. As new to java, so i thought better to take guidance instead of doing something stupid.
In my jtable, i have following data
Id | Name | Date(month-year)
1 | XYZ | August-2014
2 | ABc | April-2014
my Modelclass is as follows
class MyTableModel extends AbstractTableModel {
private String[] columnNames = {"Id", "Country","Date"};
public final Object[] longValues = {Integer.class,"",Date.class};
now as recommended, i have overriden the getColumnClass in my model table
@Override
public Class getColumnClass(int c)
{
if(c == 2)
{
//return Date.class;
return getValueAt(0,c).getClass();
}
else
return getValueAt(0,c).getClass();
}
and i have enabled default column sorter.
Now as default, all string columns work fine in shorting but for Date column also it consider as string and short it as string.
If i force the column to short as date it give me error.
What am i doing wrong and what is correct way of doing it.
Thanks