⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wannianli.txt

📁 最简单的java万年历实现
💻 TXT
字号:
HttpSession session = request.getSession();
		//获取从页面传递过来的日期
		String time = request.getParameter("time");
		if (time == "") {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			time = sdf.format(new Date());
		}
		//截取年数
		int year = Integer.parseInt(time.substring(0,4));
		//截取月份
		int month = Integer.parseInt(time.substring(5,7))-1;
		//截取日期
		int today = Integer.parseInt(time.substring(8));
		//构造日历对象
		GregorianCalendar calendar = new GregorianCalendar(year,month,today);
		//将日历对象设置为这个月的第一天,并获得这一天为星期几。
		calendar.set(Calendar.DAY_OF_MONTH, 1);
		int weekday = calendar.get(Calendar.DAY_OF_WEEK);
		Vector vectorday = new Vector();
		for (int i = Calendar.MONDAY; i < weekday; i++) {
			vectorday.add("&nbsp;");
		}
		session.setAttribute("today", today);
		session.setAttribute("year", year);
		session.setAttribute("month", month+1);
		do {
			int day = calendar.get(Calendar.DAY_OF_MONTH);
			vectorday.add(day);
			calendar.add(Calendar.DAY_OF_MONTH, 1);
		} while (calendar.get(Calendar.MONTH) == month);
		session.setAttribute("vectorday", vectorday);
		response.sendRedirect("../index.jsp");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -