文章详情页
java - 显示的时间能不能去掉毫秒
浏览:153日期:2023-10-26 13:24:13
问题描述
数据库里面的时间是DateTime类型的获取时间
public Timestamp getDatetime() {return new Timestamp(System.currentTimeMillis()); }
能不能去掉啊好难看
问题解答
回答1:看起来应该是在 Timestamp 转 String 的时候,直接调用了 Timestamp 的 toString 方法。最简单的办法就是你找到显示的地方,将 String str = timestamp.toString() 类似的代码改为
String str = timestamp.toString();str = str.substring(0, str.length() - 4);回答2:
使用SimpleDateFormat将Timestamp转为String类型。
public Timestamp getDatetime() { SimpleDateFormat df = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss'); Timestamp now = new Timestamp(System.currentTimeMillis()); String str = df.format(now);return str;}
标签:
java
相关文章:
1. 跟着课件一模一样的操作使用tp6,出现了错误2. PHP类属性声明?3. angular.js - 这是什么错?谁遇到过?给点提示4. transform - css3 translate 的水平垂直居中问题求解5. angular.js - angular里的ui-view里,获取当前页面的状态参数用$state.params,在vue里类似的语法是什么呢?6. javascript - 安装了babel,不起作用7. vue.js - nginx怎么修改跨域配置?8. css - div外层有一圈白色9. node.js - 初次安装vue-cli遇到的问题10. 前端 - 应该先从angularJS , vue.js , react 这些框架中的哪个开始入手?
排行榜
