由String构造Date类型,可以借助SimpleDateFormat类:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date1 = format.parse(rs.getString("beginDate"));
Date date2 = format.parse(rs.getString("endDate"));
String duration = String.valueOf(((date2.getTime() - date1.getTime())/(24*60*60*1000))) ;
} catch (ParseException e) {
e.printStackTrace();
}