Mysql method to remove the millisecond value: 1. Remove the millisecond value through the "public static Timestamp getSystemTime(){...}" method; 2. Remove the millisecond value by using JSTL.
Recommended: "mysql video tutorial"
Read the timestamp type in the database and remove milliseconds
The time queried in the database is: 2015-09-24 14:30:26.2, with milliseconds included, which needs to be removed.
Method one:
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; }
Method two:
-------------如果Web客户端需要使用,建议使用JSTL---------------- <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"% > <fmt:formatDate value="${}" pattern="yyyy-MM-dd HH:mm:ss" />
The above is the detailed content of How to remove milliseconds value in mysql. For more information, please follow other related articles on the PHP Chinese website!