Java : convert long to Timestamp

2019-02-04 11:10发布

问题:

I know, how to convert a Timestamp to a long, with the getTime() method.

Is there a method that convert a long to a TimeStamp?

回答1:

The constructor is doing that:

Timestamp(long time) 


回答2:

See: Timestamp.Timestamp(long):

new Timestamp(someLong)


回答3:

Yes, there's a constructor for Timestamp that takes a long as a parameter. http://docs.oracle.com/javase/6/docs/api/java/sql/Timestamp.html#Timestamp(long)