Home  >  Article  >  Database  >  How to remove milliseconds value in mysql

How to remove milliseconds value in mysql

藏色散人
藏色散人Original
2020-10-28 09:42:033902browse

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.

How to remove milliseconds value in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn