mysql去掉毫秒值的方法:1、通過“public static timestamp getsystemtime(){…}”方法去掉毫秒值;2、通過使用jstl去掉毫秒值。
推薦:《mysql視頻教程》
讀取數(shù)據(jù)庫中timestamp類型去掉毫秒
數(shù)據(jù)庫中查詢出來的時(shí)間是: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---------------- <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"% ><fmt:formatdate value="${}" pattern="yyyy-mm-dd hh:mm:ss" />