功能:实现对系统当前时间(time)与用户指定的一个时间进行比较源码:
<%@page import="java.util.*,java.text.*" %>
<HTML>
<HEAD><TITLE>JSP  to  display  the  current  time</TITLE></HEAD>
<BODY>
The  current  time  is:  
<%
Date now=new Date();
    SimpleDateFormat formatter;
    formatter = new SimpleDateFormat ("HH:mm:ss");
    String nowtime = formatter.format(now);
  out.println(nowtime);
String myString = "15:00:00";
Date d = formatter.parse(myString); 
boolean flag = d.before(nowtime);
if(flag)  
    out.println("时间小于15点");
  else 
    out.println("时间大于15点");
 
%>
</BODY>
</HTML>错误提示:
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 7 in the jsp file: /test.jsp
Generated servlet error:
The method before(Date) in the type Date is not applicable for the arguments (String)谢谢,请大家给予帮助!