The from(Instant inst) method of Java Date class returns an instance of date which is obtained from an Instant object.
public static Date from(Instant inst)
Parameters: The method takes one parameter inst of Instant type which is required to be converted.
Return Value: The method returns a date representing the same point on the timeline as the passing instant.
- NullPointerException: This is thrown when the instant is left null.
- IllegalArgumentException: This is thrown when the instant is too large to be represented as a Date.
Below programs illustrate the use of from() Method in Java:
Present: Tue Mar 26 06:45:40 UTC 2019
Date: Wed Jan 30 06:45:43 UTC 2019
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.