求 判断输入日期是否大于本月最后一天的方法
求判断输入日期是否大于本月最后一天的方法
例如:输入日期为2007-06-31 怎样判断其正确性呢?
跪求
------解决方案--------------------Calendar c = Calendar.getInstance();
c.setTime(new Date());
int nowYear = c.get(Calendar.YEAR);
int nowMonth = c.get(Calendar.MONTH);
c.set(Calendar.MONTH, nowMonth + 1);
c.set(nowYear, nowMonth, 0, 23, 59, 59);
Date nextDate1 = c.getTime();
c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH) - 1);
Date nextDate2 = c.getTime();
if (inputDate.after(nextDate1)){
System.out.println( "> ");
}else if(inputDate.before(nextDate2)){
System.out.println( " < ");
}else{
System.out.println( "= ");
}