如何在jsp和html页面上获取当前时间

要想在JSP页面中获得当前时间并显示出来,首先得导入相关的Java包,然后创建Date对象。

<%@page import="java.text.SimpleDateFormat,java.util.Date"%>
<%
String thisYear=new SimpleDateFormat("yyyy").format(new Date());
%>

在html中显示则使用

<%=thisYear%>

在html页面中获得当前时间

<span>Copyright @' + new Date().getFullYear() +'  Briefing.com, Inc. All rights reserved.</span>