class Mydate{
public Mydate(){}
public static boolean isLegalDate(String strDate)
{
int intY,intM,intD;
int[]standardDays={31,28,31,30,31,30,31,31,30,31,30,31};
int[]leapyearDays={31,29,31,30,31,30,31,31,30,31,30,31};
if (strDate==null||strDate.trim().equals("")||strDate.trim().length()!=10)return false;
strDate=strDate.trim();
try{
intY=Integer.parseInt(strDate.substring(0,4));
intM=Integer.parseInt(strDate.substring(5,7));
intD=Integer.parseInt(strDate.substring(8));
}catch(Exception e){return false;}
if (intM>12||intM<1||intY<1||intD<1)return false;
if ((intY%4==0&&intY%100!=0)||intY%400==0)return (intD<=leapyearDays[intM-1]);
return (intD<=standardDays[intM-1]);
}
}
嘻~~~~~~~~~~~~~~~~~~~~~~~~