I want to insert date from jquery datepicker to database.
String startDate = request.getParameter("datepicker");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"MM/dd/yyyy");
Date tempDate = simpleDateFormat.parse(startDate);
SimpleDateFormat outputDateFormat = new SimpleDateFormat(
"dd-MM-YYYY");
out.println("Output date is = " + outputDateFormat.format(tempDate));
i'm using ps.setDate(1,***)
, here i'm unable to understand how to convert tempDate
to sqldate and place it in ***
place above and finally insert it into database.
please let me know how can i do this.
Thanks
答案 0 :(得分:1)
You need:
ps.setDate(1, new java.sql.Date(tempDate.getTime()));