怎样判断一个月中,每周的周六,周日</select>
<option value="1">一月</option>
<option value="2">二月</option>
<option value="3">三月</option>
<option value="4">四月</option>
<option value="5">五月</option>
<option value="6">六月</option>
<option value="7">七月</option>
<option value="8">八月</option>
<option value="9">九月</option>
<option value="10">十月</option>
<option value="11">十一月</option>
<option value="12">十二月</option>
</select>
如果选种,其中一个月,就要显示这个月每周的周六周日
Calendar
<option value="1">一月</option>
<option value="2">二月</option>
<option value="3">三月</option>
<option value="4">四月</option>
<option value="5">五月</option>
<option value="6">六月</option>
<option value="7">七月</option>
<option value="8">八月</option>
<option value="9">九月</option>
<option value="10">十月</option>
<option value="11">十一月</option>
<option value="12">十二月</option>
</select>
如果选种,其中一个月,就要显示这个月每周的周六周日
Calendar
解决方案 »
- 求助,如何查找调用类
- jasperreport+ireport做报表处理logon(处理图片显示的问题),多谢大家帮助?急!!!!!!!!!!!!!!!!
- Struts+DAO做的登录小程序 求大侠帮下忙看那里出错了...小弟新手
- HSSFCell 生成Excel,行数为4000多时,打开excel,提示“不同的单元格格式太多”消息,如何处理?
- seeion有什么用处
- 请教:如何写小型JSP项目网络书城的需求分析?
- jsp中文搜索的问题.请高手帮忙@
- TOMCAT中的socket问题,请高手帮忙!
- 如何将整型数据转换成字符的
- 在JSP页面脚本中可以定义一个函数吗?
- struts中怎么使用隐藏表单
- 朋友么帮帮忙啊 (在线)
import java.text.SimpleDateFormat;
public class ShowMonths
{
public static void main(String[] args)
{
//本例子显示今年10月份的
System.out.println("Hello World!");
String ff [] = new String[8];
int year=2007;
int month=9;
String y = " 是 星期六";
String n = " 是 星期日";//月数是从0开始的,
Calendar c = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
c.set(year,month,1);
int i=0;
while(true)
{
if(c.get(Calendar.MONTH)>month)
{
//表示进入到下一个月去了
break;
}
//星期六
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY)
{
ff[i]=format.format(c.getTime())+y;
i++;
}
//星期日
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
{
ff[i]=format.format(c.getTime())+n;
i++;
}
c.add(Calendar.DAY_OF_MONTH,1);
}
for (int j=0;j<ff.length;j++ )
{
System.out.println(ff[j]);
}
}
}
就是页面,而且周六日,还要标住出来,,
1 city.jscities = new Object();cities['1月']=new Array('7日周六', '14日周日');
cities['2月']=new Array('8日周六', '15日周日');
cities['3月']=new Array('8日周六', '15日周日');
function set_city(province, city)
{
var pv, cv;
var i, ii; pv=province.value;
cv=city.value; city.length=1;if(pv=='0') return;
if(typeof(cities[pv])=='undefined') return; for(i=0; i<cities[pv].length; i++)
{
ii = i+1; city.options[ii] = new Option();
city.options[ii].text = cities[pv][i];
city.options[ii].value = cities[pv][i];
}}function cha(){
if (document.myform.u_username.value=="")
{
alert("用户名不能为空!");
}
else
{
var str_cha = document.myform.u_username.value;
location.href="cha.aspx?str=" + str_cha;
}
}2 一个html文件,任意名保存即可<script type="text/javascript" src="city.js"></script><script language="javascript">
function doSubmit(){
if (document.getElementById("province").style.display!='none')
{
if (document.form1.province.value == "0"){
alert ("提示:\n\n必须选择月份");
document.form1.province.focus();
return false;
}
}if (document.getElementById("city").style.display!='none')
{
if (document.form1.city.value == "0"){
alert ("提示:\n\n必须选择月份");
document.form1.city.focus();
return false;
}
}
}
</script> <form name="form1" action="" method="get">
<td width="41" height="34" class="style4">按月份</td>
<td width="295" valign="middle"><select name="province" onChange="set_city(this, this.form.city);">
<option value="0">选择月份</option>
<option value="1月">1月</option>
<option value="2月">2月</option>
<option value="3月">3月</option>
</select>
<select name="city" id="citys" >
<option value="0">周末</option>
</form>
必需有年数的啊,不现同年数同月的周末也不一的啊. import java.util.Calendar;
package events;
import java.text.SimpleDateFormat;
public class ShowMonths
{
public String[] getS(int year,int month)
{
//本例子显示今年10月份的
System.out.println("Hello World!");
String ff [] = new String[8];
String y = " 是 星期六";
String n = " 是 星期日";//月数是从0开始的,
Calendar c = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
c.set(year,month,1);
int i=0;
while(true)
{
if(c.get(Calendar.MONTH)>month)
{
//表示进入到下一个月去了
break;
}
//星期六
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY)
{
ff[i]=format.format(c.getTime())+y;
i++;
}
//星期日
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
{
ff[i]=format.format(c.getTime())+n;
i++;
}
c.add(Calendar.DAY_OF_MONTH,1);
}
for (int j=0;j<ff.length;j++ )
{
System.out.println(ff[j]);
}
}
}a.jsp<%@ page pageEncoding="GBK" %>
<%@ page import="events.ShowMonths" %>
<html>
<head>
</head>
<body>
<%
if(request.getParameter("year")!=null)
{
int year = Integer.parseInt(request.getParameter("year"));
int month = Integer.parseInt(request.getParameter("month"));
ShowMonths show = new ShowMonths();
String ff[]=show.getS(year,month-1);
for(int i=0;i<ff.length;i++)
{
out.println(ff[i]);
}
}
%>
<form action="a.jsp">
输入年数<input type="year">
输入月数<input type="month">
<input type="submit" value="提交">
</form>
</body>
</html>如果这样子写你还要更详细.那我没办法帮你了
{
System.out.println(ff[j]);
}
把其中的这些换成return ff;
a.jsp<%@ page pageEncoding="GBK" %>
<%@ page import="java.util.Calendar,java.text.SimpleDateFormat">
<html>
<head>
</head>
<body>
<%
if(request.getParameter("year")!=null)
{
int year = Integer.parseInt(request.getParameter("year"));
int month = Integer.parseInt(request.getParameter("month"));
String ff [] = new String[8];
String y = " 是 星期六";
String n = " 是 星期日";//月数是从0开始的,
Calendar c = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
c.set(year,month,1);
int i=0;
while(true)
{
if(c.get(Calendar.MONTH)>month)
{
//表示进入到下一个月去了
break;
}
//星期六
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY)
{
ff[i]=format.format(c.getTime())+y;
i++;
}
//星期日
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
{
ff[i]=format.format(c.getTime())+n;
i++;
}
c.add(Calendar.DAY_OF_MONTH,1);
}
for(int i=0;i<ff.length;i++)
{
out.println(ff[i]);
}
}
%>
<form action="a.jsp">
输入年数<input type="year">
输入月数<input type="month">
<input type="submit" value="提交">
</form>
</body>
</html>
<%@ page import="java.util.Calendar,java.text.SimpleDateFormat"%>
<html>
<head>
</head>
<body>
<%
if(request.getParameter("year")!=null)
{
int year = Integer.parseInt(request.getParameter("year"));
int month = Integer.parseInt(request.getParameter("month"))-1;
String ff [] = new String[8];
String y = " 是 星期六";
String n = " 是 星期日";//月数是从0开始的,
Calendar c = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
c.set(year,month,1);
int i=0;
while(true)
{
if(c.get(Calendar.MONTH)>month)
{
//表示进入到下一个月去了
break;
}
//星期六
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY)
{
ff[i]=format.format(c.getTime())+y;
i++;
}
//星期日
if(c.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
{
ff[i]=format.format(c.getTime())+n;
i++;
}
c.add(Calendar.DAY_OF_MONTH,1);
}
for(i=0;i<ff.length;i++)
{
out.println(ff[i]+"</br>");
}
}
%>
<form action="a.jsp">
输入年数<input name="year">
输入月数<input name="month">
<input type="submit" value="提交">
</form>
</body>
</html>