標籤:cond www oct title har imp 文法 import dtd
<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*" 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>jsp基本文法應用案例</title>
</head>
<body>
<center>
<%
Date today=new Date();
int year0=today.getYear();
int year=year0+1900;
int month0=today.getMonth();
int month=month0+1;
int date=today.getDate();
int day=today.getDay();
int hours=today.getHours();
int minutes=today.getMinutes();
int seconds=today.getSeconds();
if(hours>=0&&hours<12){
out.println("朋友們,早上好!");
} else if(hours>=12&&hours<19){
out.println("朋友們,下午好!");
} else
out.println("朋友們,晚上好!");
out.println("<br>現在是:"+year+"年"+month+"月"+date+"日星期"+day+"<br>"+hours+"時"+minutes+"分"+seconds+"秒");
%></center>
</body>
</html>
Java web outTime.jsp