Java獲取服務器時間
本 人是給電視做系統
<%@ page language="java" import="java
<%@page import="java
<%
String path = request
String basePath = request
%>
<!DOCTYPE HTML PUBLIC "
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP
<meta http
<meta http
<meta http
<meta http
<meta http
<!
<link rel="stylesheet" type="text/css" href="styles
</head>
<body>
<%
Calendar rightNow = Calendar
SimpleDateFormat format = new SimpleDateFormat("yyyy
%>
<script language="javascript">
//從服務器上獲取初始時間
var currentDate = new Date(<%=new java
function run()
{
currentDate
var time = "";
var year = currentDate
var month = currentDate
var day = currentDate
var hour = currentDate
var minute = currentDate
var second = currentDate
if(hour <
time += "
}else{
time += hour;
}
time += ":";
if(minute <
time += "
}else{
time += minute;
}
time += ":";
if(second <
time += "
}else{
time += second;
}
document
}
window
</script>
<div id="dt">自動顯示時間
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19931.html