在JSP的代码段中,编写程序实现将当前日期显示为“XXXX年XX月XX
日”的形式(查找JDK的文档获取帮助)
<%@ page language="java" pageEncoding="GBK"%>
<%@ page import="java.util.*,java.text.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>当前时间</title>
</head>
<body>
<%Date nowday=new Date();
SimpleDateFormat format=new SimpleDateFormat("yyyy年MM月dd日");
String time=format.format(nowday);
out.print(time);
%>
</body>
</html>
执行结果为: