// 取某月的天数,strMonth的格式是"yyyy.MM"
public static int getDaysInAMonth(String strMonth) {
String[] arr=strMonth.split("[.]");
// Create a calendar object of the desired month
Calendar cal = new GregorianCalendar(Integer.parseInt(arr[0]),Integer.parseInt(arr[1])-1, 1);
// Get the number of days in that month
int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
return days;
}
// 某月第一天是周几,strMonth的格式是"yyyy.MM"
public static int getWeekOfFirstDay(String strMonth){
String[] arr=strMonth.split("[.]");
Calendar xmas = new GregorianCalendar(Integer.parseInt(arr[0]),Integer.parseInt(arr[1])-1, 1);
int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK)-1;
return dayOfWeek;
}
