How to convert from java.sql.Timestamp to java.util.Date?

后端 未结 8 1519
心在旅途
心在旅途 2020-12-03 02:49

i.e. this code

startDate = new Date(timestampValue.getTime));

gives me :

2012-16-02 05:16:17

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 02:51

    Class java.sql.TimeStamp extends from java.util.Date.

    You can directly assign a TimeStamp object to Date reference:

    TimeStamp timeStamp = //whatever value you have;
    Date startDate = timestampValue;
    

提交回复
热议问题