自定义日期和字符串之间的类型转换器另附把字符串解析成日期的方法
import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;public class Demo {public static void main(String[] args) {String strdate = "1990-12-32";/*SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");format.setLenient(false);try {Date date = format.parse(strdate);String localdate = format.format(date);System.out.println(localdate);} catch (ParseException e) {System.out.println("格式不对");}*///用这个类转换12-32时就会抛异常DateLocaleConverter dcl = new DateLocaleConverter();try {dcl.convert(strdate, "yyyy-MM-dd");} catch (Exception e) {System.out.println("格式不对");}}}