Home > Database > Mysql Tutorial > How to remove milliseconds value in mysql

How to remove milliseconds value in mysql

藏色散人
Release: 2020-10-30 16:53:38
Original
3970 people have browsed it

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;
}
Copy after login

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" />
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template