Java Timestamp from() MethodThe from() method of Timestamp class obtains an instance of Timestamp from an Instant object. SyntaxParametersThe parameter 'instant' represents the instant to convert. ReturnsThe from() method of Timestamp class returns an Timestamp which represents the same point on the time-line as that of instant. ThrowsThe from() method of Timestamp class throws : NullPointerException- if the instance is null. IllegalArgumentException-if the instant is too large to represent as a Timestamp Example 1Output: from() method will return 2018-09-02 22:05:31.689 Example 2Output: from() method will return 1970-01-01 05:41:18.0 Example 3Output: Exception in thread "main" java.lang.NullPointerException at java.sql.Timestamp.from(Timestamp.java:598) at com.javaTpoint.JavaTimestampFromExample3.main(JavaTimestampFromExample3.java:8) Next TopicJava-timestamp-getnanos-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India