mysql语法如何去掉时间的毫秒值

2025年02月06日 建站教程

利用mysql数据库中查询出来的时间有可能会带毫秒2023-02-09 20:11:55.7,如何利用mysql语法如何去掉时间的毫秒值?下面web建站小编给大家详细介绍一下具体实现代码!

解决方法如下:

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;
}

本文链接:http://so.lmcjl.com/news/22654/

展开阅读全文