I have a timestamp object and need to get the milliseconds from it, can someone help me with an example code snippet ?
You need to simply divide the milliseconds value by 1000 and you will get the value in seconds.
This is the number of seconds since the 1970 epoch. To convert seconds to milliseconds, you need to multiply the number of seconds by 1000. To convert a Date to milliseconds, you could just call timeIntervalSince1970 and multiply it by 1000 every time.
You can use Timestamp.getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Timestamp object.
Example:
long timeInMilliSeconds = t.getTime(); // do magic trick here
Note: Timestamp is extend from Date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With