//导入
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Date dt=new Date();//如果不需要格式,可直接用dt,dt就是当前系统时间
DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//设置显示格式
String nowTime="";
nowTime= df.format(dt);//用DateFormat的format()方法在dt中获取并以yyyy/MM/dd HH:mm:ss格式显示
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat" %>
<%@page import="java.text.DateFormat" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>第一个页面</title>
</head>
<body>
<%out.print("我的JSP页面!"); %>
<%
Date dt= new Date();
DateFormat df =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String myDate= df.format(dt);
out.println(myDate);%>
</body>
</html>
原文:http://www.cnblogs.com/chenmfly/p/4296150.html