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

后端 未结 8 1517
心在旅途
心在旅途 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:55

    You should use a Calendar instead:

    Calendar start = Calendar.getInstance();
    start.setTimeInMillis( timeStampValue.getTime() );
    

提交回复
热议问题