You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gdms/web/home/get_time.jsp

32 lines
884 B

6 years ago
<%--
Created by IntelliJ IDEA.
User: lenovo
Date: 2019/1/10
Time: 22:30
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.Date" import="java.io.*,java.util.*" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<div class="updated"><%
// 设置每隔5秒自动刷新
response.setIntHeader("Refresh", 5);
// 获取当前时间
Calendar calendar = new GregorianCalendar();
String am_pm;
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
if(calendar.get(Calendar.AM_PM) == 0)
am_pm = "AM";
else
am_pm = "PM";
String CT = hour+":"+ minute +":"+ second +" "+ am_pm;
out.println("当前时间: " + CT + "\n");
%></div>
</body>
</html>