1、对dateTime时间类型的获取
数据库中时间为2013-4-9 10:14:29,使用String regTimeTemp = rs.getString("regTime");获取时间的结果是2013-4-9 10:14:29.0,最后一个表示毫秒数,需要截取字符串
public static String stringToString(String date){
String str = null;
if(date !=null){
str = date.substring(0,19);
}
return str;
}
2、对timeStamp时间类型的获取
先使用rs.getTimestamp("insertTime")获取时间,在使用SimpleDateFormat对他进行格式化就可以了
转载于:https://blog.51cto.com/3114158/1172776