Java Timestamp.getTime
时间: 2024-01-18 16:05:06 浏览: 38
The `Timestamp.getTime()` method in Java returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this `Timestamp` object. This method returns a `long` value representing the time in milliseconds.
Here's the method signature:
```
public long getTime()
```
And here's how you can use it:
```
// Create a new Timestamp object
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
// Get the timestamp value as a long
long ts = timestamp.getTime();
// Print the timestamp value
System.out.println("Timestamp value in milliseconds: " + ts);
```
In this example, we create a new `Timestamp` object using the current system time, and then call the `getTime()` method to get the timestamp value as a `long`.
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)