JSP calendar.get 取得今天日期
<%@ page contentType="text/html;charset=big5" %>
<%@ page session="true" import="java.util.*,java.io.*,com.util.io.*,com.project.*,com.util.other.*,com.DAO.* " %>
<%!
private String week(int n){
String [] w={"日","一","二","三","四","五","六"};
return w[n-1];
}
%>
<HTML>
<HEAD>
<TITLE>測試傳回日期</TITLE>
</HEAD>
<BODY>
<%
int y,m,d,n;
Calendar calendar=new GregorianCalendar();
y=calendar.get(Calendar.YEAR);
m=calendar.get(Calendar.MONTH)+1;
d=calendar.get(Calendar.DATE);
n=calendar.get(Calendar.DAY_OF_WEEK);
out.println(y + "年" + m + "月" + d + "日" + "(" + week(n) + ")");
%>
</BODY>
</HTML>
留言
張貼留言