How to convert string Date to Timestamp in Java for the format dd-MMM-yyyy?
I want to convert string Date to Timestamp in java. The following are the
codes that I have written. The date value passed is in the format
19-SEP-2013.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
Date date = dateFormat.parse(tcmo.getCtsDate());
ps.setTimestamp(ctr++, new Timestamp(date.getTime());
The variable ctr is declared already. ps is the PreparedStatement object.
Later codes include ps.executeUpdate().
tcmo.getCtsDate() returns the value 19-Sep-2013.
Database can accept only Timestamp in the format 2013-09-19 00:00:00.0
The exception thrown is Unparseable Date "19-SEP-2013". can anyone help me
to clear this?
No comments:
Post a Comment