mysql 如何去掉毫秒值
时间:2020-10-30 16:53
mysql去掉毫秒值的方法:1、通过“public static Timestamp getSystemTime(){...}”方法去掉毫秒值;2、通过使用JSTL去掉毫秒值。 推荐:《mysql视频教程》 读取数据库中timestamp类型去掉毫秒 数据库中查询出来的时间是:2015-09-24 14:30:26.2,带有毫秒,需要去掉。 方法一: 方法二: 以上就是mysql 如何去掉毫秒值的详细内容,更多请关注gxlsystem.com其它相关文章!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" />