for (final Object[] obj : leaveObjects) {
for (int i = 0; i < obj.length; i++){
try {
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(
Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql,
new String[] { "pk_CompOff_compOffId" });
ps.setInt(1, (Integer)obj[0]);
ps.setInt(2, (Integer)obj[1]);
ps.setInt(3, (Integer)obj[2]);
ps.setInt(4, (Integer) obj[3] );
try {
ps.setDate(5, new java.sql.Date(formatter.parse(obj[4].toString()).getTime()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am trying to save this date from java to the database using spring jdbc template using the above code but getting this exception:
java.text.ParseException: Unparseable date: "Sun Feb 15 00:00:00 PST 2015"
.
i am using this formatter
SimpleDateFormat formatter = new SimpleDateFormat("EEEE, MMM dd, yyyy HH:mm:ss a");
How I can resolve that?