BeanUtils——类型转换器

问题:BeanUtils不能封装Date的类型,他只会把他认为是字符串

解决方法:使用类型转换器转换

//2、指定一个类型转换器(String转换为Date),birthday传过来是String
ConvertUtils.register(new Converter() {

	public Object convert(Class clazz, Object value) {
		//将String转换为Date
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date parse = null;
		try {
			parse = format.parse(value.toString());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return parse;
	}
			
}, Date.class);

BeanUtils——类型转换器