文章详情页
java - 显示的时间能不能去掉毫秒
浏览:336日期: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. 为什么我的网页不能运行到右侧看效果?2. ios - Crash Log 里关于微信SDK的问题3. javascript - 一个前端的自我修养4. mysql单项同步5. html5 - 自己的H5页面如何集成支付宝支付6. mysql - thinkphp中join关联表后后save操作出现问题7. python3.5 urllib.parse.unquote 乱码8. objective-c - iOS开发支付宝和微信支付完成为什么跳转到了之前开发的一个app?9. python - 求助,ValueError: View function did not return a response10. 大家好,我想请问一下怎么做搜索栏能够搜索到自己网站的内容。
排行榜

网公网安备