Date from() method in Java with Examples
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