62,623
社区成员
发帖
与我相关
我的任务
分享[code=Java][/code]import java.util.Date;
class Test{
public static void main(String[] args){
String day=new Integer(Test.getLastDay(2007,4)).toString();
System.out.println(day);
}
public static int getLastDay(int year,int month){
int new_year=year;
int new_month=month++;
if(month>12){
new_month-=12;
new_year++;
}
Date new_date=new Date(new_year,new_month,1);
return (new Date(new_date.getTime()-1000*60*60*24)).getDate();
}
}