Make a simple calendar __js in a JSP

Source: Internet
Author: User
<%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>
<%@ page language= "java" import= "java.util.*"%>
String[] weekdays={"", "Day", "one", "two", "three", "four", "five", "six"};
String[] Days=new string[42];
for (int i=0;i<42;i++)
Days[i]= "";

GregorianCalendar currentday = new GregorianCalendar ();
int year= currentday.get (calendar.year);
int Month=currentday.get (calendar.month);
int Today=currentday.get (calendar.day_of_month);
int Weekday=currentday.get (Calendar.day_of_week);

String now=year+ "Year" + (month+1) + "month" +today+ "Day" + "Week" +weekdays[weekday];

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<maxindex;i++) {
Days[firstindex+i]=string.valueof (i+1);

<title> Simple Perpetual Calendar </title>
<link type= "Text/css" rel= "stylesheet" href= "<s2:url value= ' css/style.css '/> '" >
<script type= "Text/javascript" >
function ShowTime (showwhere) {
var now=new Date ();
var hour=now.gethours ();
var minu=now.getminutes ();
var sec=now.getseconds ();

if (hour<10) hour= "0" +hour;
if (minu<10) minu= "0" +minu;
if (sec<10) sec= "0" +SEC;

showwhere.value=hour+ ":" +minu+ ":" +SEC;
SetTimeout ("ShowTime (Time)", 1000)
<body onload= "ShowTime (Time)" >
<table width= "210" border= "0" align= "center" cellspacing= "1" >
<tr height= "><td colspan=" 7 "align=" center "style=" border:0 solid "><%=now%> <input type=" text "Style=" Border:0;background-color: #F9F9F9 "disable= true" id= "Time" size= "9" ></td></tr>
<tr height= "bgcolor=" "#F0F0F0" align= "Center" >
&LT;TD style= "border:1 solid" > Day </td>
&LT;TD style= "Border:1 solid" > </td>
&LT;TD style= "Border:1 solid" > Two </td>
&LT;TD style= "Border:1 solid" > Three </td>
&LT;TD style= "Border:1 solid" > Four </td>
&LT;TD style= "Border:1 solid" > Five </td>
&LT;TD style= "Border:1 solid" > Six </td>
&LT;TR height= "4" ><td colspan= "7" ></td></tr>
<% for (int j=0;j<6;j++) {%>
for (int i=j*7;i< (j+1) *7;i++) {
if ((i-firstindex+1) ==today) {%>
&LT;TD width= "height=" align= "center" bgcolor= "Gray" style= "border:1 solid" ><font color= "#FFFFFF" > <b><%=days[i]%></b></font></td>
&LT;TD width= "height=" align= "center" style= "border:1 solid" ><%=days[i]%></td>
&LT;TR height= "Ten" ><td colspan= "7" ></td></tr>

gets the month in the Calendar wrapper class, using the calendar. Day_of_month gets the first one months of the current month

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.