Java programming learning: DIY a JSP calendar-Linux general technology-Linux programming and kernel information. The following is a detailed description. Java programming learning: DIY a JSP calendar by yourself. This is the source code. You only need to run it to know the result. <% @ Page contentType = "text/html; charset = gb2312" language = "java" import = "java. SQL. * "errorPage =" "%> <% @ page language =" java "import =" java. util. * "%> <%! String days []; %><% Days = new String [42]; for (int I = 0; I <42; I ++) {days
= "" ;}%> <% GregorianCalendar currentDay = new GregorianCalendar (); int today = currentDay. get (Calendar. DAY_OF_MONTH); int month = currentDay. get (Calendar. MONTH); int year = currentDay. get (Calendar. YEAR); out. println (year + "year" + (month + 1) + "month" + today + "day"); Calendar thisMonth = Calendar. getInstance (); thisMonth. set (Calendar. MONTH, month); thisMonth. set (Calendar. YEAR, year); thisMonth. setFirstDayOfWeek (Calendar. SUNDAY); thisMonth. set (Calendar. DAY_OF_MONTH, 1); int firstIndex = thisMonth. get (Calendar. DAY_OF_WEEK)-1; int maxIndex = thisMonth. getActualMaximum (Calendar. DAY_OF_MONTH); for (int I = 0; I
Day |
I |
II |
3. |
Thu |
V. |
Sat. |
<% For (int j = 0; j <6; j ++) {%>
<% For (int I = j * 7; I <(j + 1) * 7; I ++) {%>
<% If (I-firstIndex + 1) = today) {%> <% = days%> <%} Else {%> <% = days%> <% }%> |