i am trying to insert html5 datepicker's date into Oracle table having datatype date,i've tried so many thing but i am still facing problem,plz help me to solve the issue.
static int addNotification(String date,String message)
{
int i=0;
try {
ps=con.prepareStatement("INSERT into ev values(?,to_date(?,'DD-MON-YYYY'))");
ps.setString(1, message);
DateFormat originalFormat = new SimpleDateFormat("yyyyMMdd");
DateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date dt = originalFormat.parse(date);
String formattedDate = targetFormat.format(dt);
System.out.println(formattedDate);
ps.setString(2, formattedDate);
// ps.setDate(2,formattedDate);
i=ps.executeUpdate();
}
everytime i am making changes , i am getting new exception for ex.
java.sql.SQLException: ORA-01861: literal does not match format string
java.text.ParseException: Unparseable date('YYYY-MM-DD')
plz help me to solve this problem.