The getTime() function is a part of Timestamp class of Java SQL.The function is used to get the time of the Timestamp object. The function returns time in milliseconds which represents the time in milliseconds after 1st January 1970.
public long getTime()
Parameters: The function does not require any parameter.
Return value: The function returns long value representing time in milliseconds.
Exception: The function does not throw any exceptions.
Below examples illustrate the use of getTime() function
Example 1: Create a timestamp and use the getTime() to get the time of timestamp object.
Timestamp time : 1970-01-01 00:00:10.0 Time in milliseconds : 10000
Example 2: Create a timestamp and use the getTime() to get the time of timestamp object and set the time before 1st January 1970. The negative long value represents the time before 1st January 1970
Timestamp time : 1969-12-31 23:59:50.0 Time in milliseconds : -10000
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Java ZipEntry getTime() function with examples
- Date getTime() method in Java with Examples
- Calendar getTime() Method in Java with Examples
- Java SQL Timestamp setTime() function with examples
- Java SQL Timestamp setNanos() function with examples
- Java SQL Timestamp before() function with examples
- Java SQL Timestamp after() function with examples
- Java SQL Timestamp getNanos() function with examples
- UUID timestamp() Method in Java with Examples
- Java Program to Convert Date to TimeStamp
- Performing Database Operations in Java | SQL CREATE, INSERT, UPDATE, DELETE and SELECT
- How to implement SQL GROUP BY in Java?
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- How to Execute Multiple SQL Commands on a Database Simultaneously in JDBC?
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.util.BitSet class in Java with Examples | Set 1
- Java.util.Collections.rotate() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.