1、Timestamp转String
public String changeTime(Timestamp time){
if (null != time) {
return new SimpleDateFormat("yyyy-MM-dd").format(time);
} else {
return "";
}
}
2、String转Timestamp
public Timestamp changeDate(String time) throws Exception(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (StringUtils.isEmpty(time)) {
return null;
}
Date date = sdf.parse(time);
Timestamp ctime = new Timestamp(date.getTime());
return ctime;
}
欢迎各位热爱学习的朋友加入Java技术交流大家庭(QQ群):422239489