package cn.org.yopcrm;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.Converter;
public class BeanUtilsTest {
/**
* @param args
* @throws Exception
* @throws IllegalAccessException
*/
public static void main(String[] args) throws IllegalAccessException, Exception {
// TODO Auto-generated method stub
/*
* BeanUtils 提供String 8种 自动的转换功能
* 当date 需要自定义转换器
*/
Student student = new Student();
BeanUtils bu = new BeanUtils();
ConvertUtils.register(new Converter(){
@Override
public <T> T convert(Class<T> type, Object value) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String sbirthday = (String) value;
try {
BeanUtils 自定义转换器
最新推荐文章于 2023-09-14 09:31:47 发布