你的是伪代码么?我也不一个一个挑问题了,直接给个JAVA编译通过的代码你自己看看吧
package com.sooinn.tools.calendar;
import java.util.*;
public class CalendarPro {
/**
* @param int year, int month
*/
public static String getCalendar( int year, int month ) {
month = month - 1;
int day = 1;
String returnValue = null;
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.SUNDAY);
calendar.set( year, month, day);
returnValue = "日 一 二 三 四 五 六";
int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
int days = 0;
switch (month) {
case Calendar.JANUARY:
case Calendar.MARCH:
case Calendar.MAY:
case Calendar.JULY:
case Calendar.AUGUST:
case Calendar.OCTOBER:
case Calendar.DECEMBER:
days = 31;
break;
case Calendar.APRIL:
case Calendar.JUNE:
case Calendar.SEPTEMBER:
case Calendar.NOVEMBER:
days = 30;
break;
case Calendar.FEBRUARY:
days = 28;
if ( year%100 != 0 ) {
if ( year%4 == 0 ) {
days = 29;
}
} else {
if ( year/100%4 == 0 ) {
days = 29;
}
}
break;
}
String[] cal = new String[week+days];
for( int i = 0; i < week; i++ ) {
cal[i]=" ";
}
int n = 1;
for(int i = week; i < week+days; i++) {
cal[i]=String.valueOf(n++);
if ( cal[i].length() == 1 ) {
cal[i] = " " + cal[i];
}
}
for(int i=0;i
returnValue = returnValue + "\n";
} else {
returnValue = returnValue + " ";
}
returnValue = returnValue + cal[i];
}
return returnValue;
}
public static void main(String[] args) {
System.out.println( CalendarPro.getCalendar( 1904, 2 ) );
}
}
法身佛