I am having trouble displaying Date
s in the format I want in my JTable
. My JTable
has been created using a ResultSet and lists.
I tried the following in getValueAt(.)
but no luck:
if(value instanceof Date)
{
//System.out.println("isDate");
DateFormat formatter = DateFormat.getDateInstance();
SimpleDateFormat f = new SimpleDateFormat("MM/dd/yy");
value = f.format(value);
Date parsed = (Date) value;
try {
parsed = (Date) f.parse(value.toString());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
value = parsed.toString();
}
The println(.)
is never printed so it isn't even getting to that. The Format that is being displayed is Apr 10, 1992
but I want 04/10/92
While we are on the topic of Date
in JTables
... I have isCellEditable(.)
as true but I cannot edit the Date cells. How do you do this?