I have a SQLite database with a date stored as VARCHAR
(yyyy-mm-dd), for example '2013-01-25'
.
My query retrieves the records from the table and displays it as stored. I need to display the VARCHAR
data in my JTable
as 'Friday January 25, 2013'. I suspect using setCellRenderer for the column containing the VARCHAR is the way to go. Further, I think it will be a two step process: first, converting the VARCHAR to a date value then formatting the date as desired. I can do so as follows if I grab the VARCHAR value from the JTable
and display it in a JTextField
:
MyDate = new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("My_Date"));
and then formatting it as desired
MyDateStr = new SimpleDateFormat("EEEE MMMM d, yyyy").format(MyDate);
That's all well and good; however, I need the formatted display in the JTable
column. I've never used setCellRenderer
, so I could use some help getting started.