哪位朋友知道怎么做吗?
解决方案 »
- 关于在jLabel上显示图片,并且图片自适应JLabel的大小
- Socket编程小问题
- 合理的程序不应尝试捕捉严重错误,如JVM错误。
- Java操作Oracle游标结果累加的问题?
- jdk 覆盖问题请帮忙谢谢
- 一个小问题急急
- 我经常去的一个比较火暴的JAVA群
- 在java中怎么把日期0204改成2002-04
- 我用JB将application打包成.JAR运行有问题,把.jar解开后,用DOS窗口运行java -classpath ...没有问题,这是怎么回事?
- 关于JAVA连接ORACLE的问题,急用,一定要帮忙!!!
- 大家知道怎么通过超连接传递参数传%,不能用POST方式
- 新手,一个搞不懂的问题!
int days=0;
if(month<0 || month>11){
days=-1;
}else{
Calendar cal=new GregorianCalendar(year,month,1);
days=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
}
return days;
}
public static void main(String[] arguments) {
int year = 2000;
if (arguments.length > 0)
year = Integer.parseInt(arguments[0]);
for (int month = 1; month < 13; month++)
for (int day = 1; day <= countDays(month, year); day++)
System.out.println(month + "/" + day + "/" + year);
} static int countDays(int month, int year) {
int count = -1;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
count = 31;
break;
case 4:
case 6:
case 9:
case 11:
count = 30;
break;
case 2:
if (year % 4 == 0)
count = 29;
else
count = 28;
if ((year % 100 == 0) & (year % 400 != 0))
count = 28;
}
return count;
}
}
/* public static void main(String[] args) throws IOException{
int year=0,month=0;
String iny=null,inm=null;
do{
System.out.println("Please input the right year and month"+"\n"+"input year:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
iny = br.readLine();
if (iny.length()==0) {
System.out.print("aaaa"+iny);
continue;
}
System.out.println("input month:");
inm=br.readLine();
if(inm == null) {System.out.print("bbb"+inm); continue;}
year=Integer.parseInt(iny);
month=Integer.parseInt(inm);
}while((month<1)||(month>12));
System.out.println(year+"."+month+" has "+cday(year,month)+" days");
}*/
public Day(){}
public int cday(int y,int m){
int day=0;
switch(m){
case 4 :
case 6 :
case 9 :
case 11 : day = 30;break;
case 2 : if (y%4==0){day=29;}else{day=28;}
if ((y%100==0)&(y%400!=0)){day=28;}break;
default : day = 31;break;
}
return(day);
}
}