我使用了一个日期选择器来选择日期格式。 现在,将此日期从jsp页面传递到servlet页面,而不是传递我推送的日期,sysdate正在传递。
Calendar cal = Calendar.getInstance();
String getdate = request.getParameter("selectDate");
String [] date = getdate.split("-");
int date1 = Integer.parseInt(date[0].trim());
int month = Integer.parseInt(date[1].trim());
int year = Integer.parseInt(date[2].trim());
java.sql.Date sD=new java.sql.Date(cal.getTimeInMillis());
System.out.println(sD);
这些是一些sysouts
In Book Support
In Database Connection
Driver is still loading...
Driver Loaded.....
Connection established.....
2013-10-28
support_id=0, booking_date=2013-10-28, descriprtion=asdasd, address=sadas, contact_number=234]
In Add Support
support_id=0, booking_date=2013-10-28, descriprtion=asdasd, address=sadas, contact_number=234]
1record added
答案 0 :(得分:0)
Calendar cal = Calendar.getInstance();
java.sql.Date sD=new java.sql.Date(cal.getTimeInMillis());
System.out.println(sD);
您创建了新的日历实例,因此结果为
使用SimpleDateFormat
将收到的String
解析为Date
并使用它来创建更多Date
个实例(如果需要)