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

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

    public static Date convertTimestampToDate(Timestamp timestamp)  {
            Instant ins=timestamp.toLocalDateTime().atZone(ZoneId.systemDefault()).toInstant();
            return  Date.from(ins);
    }
    

提交回复
热议问题