我用eclipse做了个小日历软件,但老师要求是用web的形式,那我怎么把这个日历显示在网页上呢,

我用eclipse做了个小日历软件,但老师要求是用web的形式,那我怎么把这个日历显示在网页上呢,,第1张

用javasript完全可以,因为是客服端的就不用了JSP,还不是表格吗,里面嵌文本,里面加点1,2,3日期,当然会有按钮,下拉框,加点好的javascript来实现业务逻辑,自己多找找吧

package com.littletest

import java.util.Calendar

public class RiLi2 {

static String[] WEEK = { "SUN", "MON", "TUS", "WEN", "THU", "FRI", "SAT" }

static String[] MONTH = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",

"Aug", "Sep", "Oct", "Nov", "Dec" }

/**

* @Title: main

* @Description: 2011-10-14 qzt:打印出一个月的日历

* @param

* @return

* @throws

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

Calendar calendar = Calendar.getInstance()

RiLi2 riLi = new RiLi2()

for (int i = 1i <= 12i++) {

riLi.setDate(calendar, 2011, i)

String[] date = new String[42]

riLi.getString(calendar, date)

riLi.printString(date, WEEK, MONTH[i - 1])

}

}

private void setDate(Calendar calendar, int year, int month) {

// Calendar里面months是0-11表示12个月

calendar.set(year, month - 1, 1)

}

private void getString(Calendar calendar, String[] date) {

int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH)// 本月的最大天数

int firstWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1// 1号是周几

int beginNum = 0, endNum = 0

// 前面填充空格

for (int i = 0i <firstWeeki++) {

date[i] = " "

beginNum = i + 1

}

// 后面填出日历

for (int i = 0i <maxDayi++) {

String numString = ""

int j = i + 1

if (j <10) {

numString = "0" + j

} else {

numString = "" + j

}

endNum = beginNum + i

date[endNum] = numString

}

// 后面填充空格

for (int i = endNum + 1i <date.lengthi++) {

date[i] = " "

}

}

private void printString(String[] date, String[] week, String month) {

System.out.println()

System.out.println("============" + month + "============")

for (int i = 0i <week.lengthi++) {

System.out.print(week[i])

System.out.print(" ")

}

System.out.println()

for (int i = 0i <date.lengthi++) {

System.out.print(date[i])

System.out.print(" ")

if (i % 7 == 6) {

System.out.println()

}

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8147773.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存