import java.text.SimpleDateFormat;
import java.util.Date;
public class TestCase {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String birthday = "2010-3-20";
TestCase testCase = new TestCase();
System.out.println(testCase.checkDate(birthday));
}
public boolean checkDate(String birthday){
boolean dateIsRight = true;
try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date tempDate = (Date)sdf.parseObject(birthday);
String tempStr = sdf.format(tempDate);
if(!tempStr.equals(birthday)){
dateIsRight = false;
}
}catch(Exception e){
dateIsRight = false;
}
return dateIsRight;
}
}