I have a a field in my database saving a date as DateTime. I wish to change its format to dd-MM-yyyy. Here is my present Java/JSP code but it is returning an exception:
DateFormat formatter ;
Date date;
formatter = new SimpleDateFormat("dd-MMM-yy");
date = (Date) formatter.parse(rs.getString("play_date")); //rs -> ResultSet
//print date...
What is the best way to be able to get the date?
Instead of:
rs.getString("play_date")you should do:since your column
play_dateis of DATE_TIME in your database. There is no need to do any parsing either. You can directly display the time indd-MM-yyyyformat using DateFormat#format(date)