这两天碰到了很头痛的问题
一直都没解决:这个主要是做一个时间的比较:我用的是SQL2000,此从数据库取出的时间和当前的系统获得的时间进行比较:
数据库放时间的字段的类型是:varchar
String year=request.getParameter("year");
String month=request.getParameter("month");
String day=request.getParameter("day");
String time=year+"-"+month+"-"+day; //此time是插入数据库的时间
此是获得当前系统的时间:
SimpleDateFormat formatterhwy=new SimpleDateFormat("yyyy-MM-dd");
java.util.Date syscurrentime=new java.util.Date();
String currentsysdate=formatterhwy.format(syscurrentime);
此是做数据库时间和系统时间的比较
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd ");
Date date1 = sdf.parse("stoptime");
Date date2 = sdf.parse("currentsysdate");
System.out.println(date1);
System.out.println(date2);
boolean isAfter = date1.after(date2);
out.println( isAfter);
其提示的错误是:
An error occurred at line: 53 in the jsp file: /Webexercise/advice/advice/jxHomeWork1.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\Webexercise\advice\advice\jxHomeWork1_jsp.java:128: incompatible types
found : java.util.Date
required: java.sql.Date
Date date1 = sdf.parse("stoptime");
^
An error occurred at line: 53 in the jsp file: /Webexercise/advice/advice/jxHomeWork1.jsp
Generated servlet error:
E:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\Webexercise\advice\advice\jxHomeWork1_jsp.java:129: incompatible types
found : java.util.Date
required: java.sql.Date
Date date2 = sdf.parse("currentsysdate");
^
请问怎么解决啊!
谢谢啊!