lang包工具类工具类

RandomStringUtils类
1 生成10位随机数字字母
RandomStringUtils.randomAlphanumeric(10);


NumberUtils类

ConvertUtils类
//BeanUtils对时间转换的初始化设置
ConvertUtils.register(new SqlDateConverter(null), java.sql.Date.class);
ConvertUtils.register(new Converter(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
SimpleDateFormat sdf_time = new SimpleDateFormat("yyyy-M-d H:m");
@SuppressWarnings("rawtypes")
public Object convert(Class type, Object value) {
if(value == null) return null;
if (value instanceof Date) return (value);
try {
return sdf_time.parse(value.toString());
} catch (ParseException e) {
try {
return sdf.parse(value.toString());
} catch (ParseException e1) {
return null;
}
}
}}, java.util.Date.class);

你可能感兴趣的:(java,sql)