您好,欢迎访问一九零五行业门户网

mysql 如何去掉毫秒值

mysql去掉毫秒值的方法:1、通过“public static timestamp getsystemtime(){...}”方法去掉毫秒值;2、通过使用jstl去掉毫秒值。
推荐:《mysql视频教程》
读取数据库中timestamp类型去掉毫秒
数据库中查询出来的时间是: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" />
以上就是mysql 如何去掉毫秒值的详细内容。
其它类似信息

推荐信息