JSP上判断上午或下午

来源:互联网 发布:msr606读写器软件 编辑:程序博客网 时间:2024/04/28 07:31

 <%@ page contentType="text/html; charset=GB18030" import="javax.servlet.http.*,java.util.*" %>
<% Calendar cd=Calendar.getInstance(); %>
<html>
<head>
<title>
chenggong
</title>
</head>
<body bgcolor="#ffffff">
<h1>
恭喜登陆成功
<%=session.getAttribute("useridsession") %>
<%if(cd.get(Calendar.AM_PM)==Calendar.AM) {%>
上午好!
<%}else{ %>
下午好!
<% }%>
</h1><a href="welcome.jsp">返回</a>
</body>
</html>

用到的包:java.util.Calendar

事例化:Calendar cd=Calendar.getInstance();

方法:if(cd.get(Calendar.AM_PM)==Calendar.AM) {
上午好!
}else{
下午好!
}

原创粉丝点击