<%@ page language="java" import="java.text.*,java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%! String format(String format,Date date){ SimpleDateFormat formater=new SimpleDateFormat(format); return formater.format(date); } %> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Insert title here</title> </head> <body> 您访问的时间是: <% Date now=new Date(); String time=format("YYYY年MM月dd日",now); %> <%=time %> </body> </html>