校验字符串转换的日期是否合法
import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;public class DateTest { private static SimpleDateFormat sdf = null; static { sdf = new SimpleDateFormat("yyyyMMdd"); //重点是这句 sdf.setLenient(false); } public static void main(String[] args) throws ParseException { validateDate("00001202"); } public static void validateDate(String str){ sdf.setLenient(false); try{ sdf.parse(str); System.out.println("success"); }catch (Exception e) { System.out.println("fail"); } }}??