例如在mysql中的一张表中存在一个字段opr_time为datetime类型,

在JDBC 中通过rs.getString("opr_time");来获取使会在日期后面添加".0",

例如日期为:2014-06-01 12:10:20 查询出来为:2014-06-01 12:10:20.0

解决方法:通过rs.getTimestamp("opr_time")获取对应的时间戳然后调用toDateStr(Timestamp tt)方法就可以。

public static String toDateStr(Timestamp tt){
        if(null!=tt){
             return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(tt);
        }
       return "";
}

 

相关文章:

  • 2021-06-06
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-07-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-11-22
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案