mysql 如何去掉毫秒值

mysql去掉毫秒值的方法:1、通過“public Static timestamp getSystemTime(){…}”方法去掉毫秒值;2、通過使用JSTL去掉毫秒值。

mysql 如何去掉毫秒值

推薦:《mysql視頻教程

讀取數(shù)據(jù)庫中timestamp類型去掉毫秒

數(shù)據(jù)庫中查詢出來的時間是:2015-09-24 14:30:26.2,帶有毫秒,需要去掉。

方法一:

public?static?Timestamp?getSystemTime() { Date?dt?=?new?Date(); DateFormat?df?=?new?SimpleDateFormat("yyyy-MM-dd?HH:mm:ss"); String?nowTime?=?df.format(dt); java.sql.Timestamp?buydate?=?java.sql.Timestamp.valueOf(nowTime); return?buydate; }

?

方法二:

?

-------------如果Web客戶端需要使用,建議使用JSTL---------------- ? <formatdate></formatdate>

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊8 分享