The time in the database is of DateTime typeGetting the time
public Timestamp getDatetime() { return new Timestamp(System.currentTimeMillis()); }
Can you remove it? It’s so ugly
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
Timestamp
String
toString
String str = timestamp.toString()
String str = timestamp.toString(); str = str.substring(0, str.length() - 4);
Use SimpleDateFormat to convert Timestamp to String type.
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; }
It seems that when
Timestamp
is converted toString
, thetoString
method ofTimestamp
is directly called.The easiest way is to find the display place and change
String str = timestamp.toString()
similar code toUse
SimpleDateFormat
to convertTimestamp
toString
type.