String date = request.getParameter("date"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); // your template here java.util.Date dateStr = formatter.parse(date); java.sql.Date dateDB = new java.sql.Date(dateStr.getTime());
如今將String date轉換爲java.sql.Date並使用另外一種方法:java
preparedStatement.setDate(4,dateDB);