Java Timestamp getTime() MethodThe getTime() method of Timestamp class returns the number of milliseconds since January 1, 1970, 00:00:00 GMT . SyntaxParametersNA ReturnsThe getNanos() method of Timestamp class returns the number of milliseconds since January 1, 1970, 00:00:00 GMT . Example 1Test it NowOutput: Timestamp : 2018-09-01 09:01:15.0 Milliseconds : 1535772675000 Example 2Test it NowOutput: Exception in thread "main" java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] at java.sql.Timestamp.valueOf(Timestamp.java:204) at JavaTimestampGetTimeExample2.main(JavaTimestampGetTimeExample2.java:5)
Next TopicJava Timestamp
|