How to extract a date from a JTable
One element I load to a JTable is a date, once it is there how do I extract the contents so that I can work with it as a date?
// Here are the dates
Date date1 = new GregorianCalendar(2009,0,26).getTime();
Date date2 = new GregorianCalendar(2008,2,20).getTime();
// Right now they are in an array, eventually they will come from a file
private Object[][] serviceTable = {
{ 97300, date1, "McElhinney's Service", 4798, "Check alternator and oil pressure", "Battery, Alternator, Serpentine Belt, Oil Pressure Sensor", 707.68},
{ 0, date2, "McElhinney's Service", 11112, "Replace engine", "Motor, cables, fluids", 4534.61}
};
private JTable table;
// Load the array into a table
private void PopulateTable()
{
for ( int r = 0; r < serviceTable.length; r++ )
for ( int c = 0; c < serviceTable[r].length; c++ )
model.setValueAt(serviceTable[r][c], r, c);
}
Later on in the code, depending on input from the user, I am going to want to extract the date that is in model.getValueAt(r,1), which is the date. I can't find anything that converts an object into a Date (either Date or Calendar).