jsp 获取并显示系统时间

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
   <%//导入时间 的包 %>
   <%@page import="java.util.*" %>
<!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>Insert title here</title>
</head>
<body>
<%
 //每隔一秒,刷新一次页面
response.setHeader("refresh","1");
//获取当前时间
Date mydate=new Date();
%>
当前时间:<%=mydate.toLocaleString()%>
</body>
</html>

显示结果:

toLocaleString()方法还不熟悉,需要查资料。

猜你喜欢

转载自blog.csdn.net/qq_37692470/article/details/84919324