文章详情页
java - 显示的时间能不能去掉毫秒
浏览:73日期: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. javascript - ionic1的插件如何迁移到ionic2的项目中2. java - 如何在Fragment中调用Activity的onNewIntent?3. javascript - h5上的手机号默认没有识别4. mysql里的大表用mycat做水平拆分,是不是要先手动分好,再配置mycat5. css - 关于input标签disabled问题6. python - 获取到的数据生成新的mysql表7. 怎么用css截取字符?8. window下mysql中文乱码怎么解决??9. javascript - jquery hide()方法无效10. python的文件读写问题?
排行榜
