package com.accphr.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.beanutils.Converter;

//自定义日期类型转换器
public class JavaUtilDateConverter implements Converter {
	private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

	public Object convert(Class type, Object value) {
		if (null == value || value.toString().trim().equals("")) {
			return null;
		}

		String s = value.toString().trim();
		try {
			Date d = this.format.parse(s);
			return d;
		} catch (ParseException e) {
			throw new RuntimeException("不支持或错误的日期格式:[" + s + "]");
		}

	}
}
最近下载更多
twingo0204  LV24 2016年1月6日
最代码官方  LV168 2012年8月22日
最近浏览更多
wenpeng182013  LV7 1月6日
13063925092  LV1 2020年5月15日
能不能不存在  LV13 2020年4月21日
fpxrng  LV9 2019年12月12日
hzhsh0223  LV18 2019年4月13日
fly666  LV11 2018年9月27日
lw19900921  LV25 2018年9月20日
李杰强  LV18 2018年6月24日
jd_lzh  LV1 2018年5月31日
eeeerer  LV9 2018年4月25日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友