String text = "1987-02-10";
Date d = null;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setLenient(false);//这个的功能是不把1996-13-3 转换为1997-1-3
try{
d = df.parse(text);
}
catch(Exception e){
d=new Date();
System.out.println("你输入的日期不合法,请重新输入");
}
String sdata=df.format(d);
System.out.println(sdata);