The time in the database is of DateTime type
Getting the time
public Timestamp getDatetime() {
return new Timestamp(System.currentTimeMillis());
}
Can you remove it? It’s so ugly
大家讲道理2017-06-23 09:16:23
It seems that when Timestamp
is converted to String
, the toString
method of Timestamp
is directly called.
The easiest way is to find the display place and change String str = timestamp.toString()
similar code to
String str = timestamp.toString();
str = str.substring(0, str.length() - 4);
代言2017-06-23 09:16:23
Use SimpleDateFormat
to convert Timestamp
to String
type.
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;
}