84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
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.