强制类型转换:string—>int,string—>date

1、string—>int
bean2.setDnum(row.get("dnum")==null0:Integer.valueOf(row.get("dnum").toString()));


2、string—>date   此时需先parse转化为Date型再format格式化

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
if(rs.getString("createTime")!=null){
ecpDownStreamBean.setCreateTime(sdf.format(sdf.parse(rs.getString("createTime"))));
}
} catch (ParseException e) {
ecpDownStreamBean.setCreateTime(rs.getDate("createTime"));
}

你可能感兴趣的:(String)