67,512
社区成员
发帖
与我相关
我的任务
分享
public class DateConverter implements Converter {
public Object convert (Class type, Object value) {
if (value == null) {
return value;
}
if (value instanceof java.util.Date) {
return value;
}
if (value instanceof String) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sdf.parse((String)value);
return d;
}
}
//注册转换器
public void init() {
ConvertUtils.register(new DateConverter(), java.util.Date.class);
}
}