1个回答
展开全部
Calendar time=Calendar.getInstance()
time.clear();
time.set(Calendar.YEAR,year); //year 为 int
time.set(Calendar.MONTH,month-1); //month 为int
int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);
某年year ,某月month ,天数day
time.clear();
time.set(Calendar.YEAR,year); //year 为 int
time.set(Calendar.MONTH,month-1); //month 为int
int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);
某年year ,某月month ,天数day
追问
本人愚钝,可以整体化一点吗
追答
public int getMaxDay(int year,int month ){
Calendar time=Calendar.getInstance()
time.clear();
time.set(Calendar.YEAR,year); //year 为 int
time.set(Calendar.MONTH,month-1); //month 为int
return time.getActualMaximum(Calendar.DAY_OF_MONTH);
}
getMaxDay(2015, 9);
调用函数就行了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询