84669 人学习
152542 人学习
20005 人学习
5487 人学习
7821 人学习
359900 人学习
3350 人学习
180660 人学习
48569 人学习
18603 人学习
40936 人学习
1549 人学习
1183 人学习
32909 人学习
数据库里面的时间是DateTime类型的获取时间
public Timestamp getDatetime() { return new Timestamp(System.currentTimeMillis()); }
能不能去掉啊好难看
看起来应该是在 Timestamp 转 String 的时候,直接调用了 Timestamp 的 toString 方法。最简单的办法就是你找到显示的地方,将 String str = timestamp.toString() 类似的代码改为
Timestamp
String
toString
String str = timestamp.toString()
String str = timestamp.toString(); str = str.substring(0, str.length() - 4);
使用SimpleDateFormat将Timestamp转为String类型。
SimpleDateFormat
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; }
看起来应该是在
Timestamp
转String
的时候,直接调用了Timestamp
的toString
方法。最简单的办法就是你找到显示的地方,将
String str = timestamp.toString()
类似的代码改为使用
SimpleDateFormat
将Timestamp
转为String
类型。