java - 显示的时间能不能去掉毫秒
本文介绍了java - 显示的时间能不能去掉毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
数据库里面的时间是DateTime类型的
获取时间
public Timestamp getDatetime() {
return new Timestamp(System.currentTimeMillis());
}
能不能去掉啊好难看
解决方案
看起来应该是在 Timestamp
转 String
的时候,直接调用了 Timestamp
的 toString
方法。
最简单的办法就是你找到显示的地方,将 String str = timestamp.toString()
类似的代码改为
String str = timestamp.toString();
str = str.substring(0, str.length() - 4);
这篇关于java - 显示的时间能不能去掉毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文