forked from GavinYGM/JavaWeb_Protects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
date.jsp
55 lines (51 loc) · 1.36 KB
/
date.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'data.jsp' starting page</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%!Date date=new Date();%>
<%!SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss "); %>
<%String d=f.format(date); %>
<h1 style="color: green;">
<%
Calendar c = Calendar.getInstance();
int h=c.get(Calendar.HOUR_OF_DAY);
if(h>0&&h<12){
out.print("主人,上午好!");
}else if(h==12){
out.print("主人,中午好!");
}else if(h>12&&h<24){
out.print("主人,下午好!");
}
%>
</h1>
<h3>现在时间是:<%=d %>
<%
String help=date.toString();
String weeks[]=help.split(" ");
String week=weeks[0];
if(week.equals("Mon")){
out.print("星期一");
}else if(week.equals("Tues")){
out.print("星期二");
}else if(week.equals("Wed")){
out.print("星期三");
}else if(week.equals("Thur")){
out.print("星期四");
}else if(week.equals("Fri")){
out.print("星期五");
}else if(week.equals("Sat")){
out.print("星期六");
}else if(week.equals("Sun")){
out.print("星期日");
}
%>
</h3>
</body>
</html>