时光紧张,先记一笔,后续优化与完善。
截取返回时光对象格式yyyy-MM-dd HH:mm:ss的字符串( 去掉时光后带的毫秒数)
Static SimpleDateFormat dateformatAll= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义返回的日期格式
//去掉后带.123时光的毫秒数方法
public static String getTimestampStringAbortMillisecond(Timestamp ts){
if(ts==null){//如果时光为空返回当前时光
return dateformatAll.format(getCurrentTimestamp());
}
return dateformatAll.format(ts);//格式化传过来的时光就能够去掉毫秒数
}
//频仍地应用new Timestamp(new Date().getTime())方法获得当前的timestamp
public static Timestamp getCurrentTimestamp(){
return new Timestamp(new Date().getTime());//获取当前的时光
}
文章结束给大家分享下程序员的一些笑话语录:
《诺基亚投资手机浏览器UCWEB,资金不详或控股》杯具了,好不容易养大的闺女嫁外国。(心疼是你养的吗?中国创业型公司创业初期哪个从国有银行贷到过钱?)