LocalDateTime from() method in Java with Examples
The from() method of LocalDateTime class is used to obtain an instance of LocalDateTime from the temporal object passed as the parameter.
public static LocalDateTime from(TemporalAccessor temporal)
Parameter: This method accepts a parameter temporal which specifies the temporal object to be converted to the LocalDateTime instance. It should not be null.
Returns: The function returns the LocalDateTime which is the converted LocalDateTime from the temporal object.
Exceptions: The program throws DateTimeException which is thrown if it is unable to convert the given date to a LocalDateTime.
Below programs illustrate the LocalDateTime.from() method: