0

我应该将日期类型作为参数从 JSP 发送到 servlet,以便插入 MySQL 数据库。当我使用 Date toDate = new java.sql.Date(format.parse(request.getParameter("to_date")).getTime()); 在 servlet 中,它总是在月份的位置显示 01。我输入日期为 2013-03-03,但它显示为 2013-01-03。请告诉我错误可能出在哪里?

4

1 回答 1

0

我不知道你是如何定义格式的,但它应该是:

DateFormat format = new SimpleDateFormat("yyyy-MM-dd");

SimpleDateFormat 构造函数中的字符串区分大小写。

于 2013-03-02T13:03:33.670 回答