The from() method of a LocalTime class helps to get instance of LocalTime from TemporalAccessor object passed as parameter to method. A TemporalAccessor represents an arbitrary set of date and time information and this method helps to get a LocalTime based on the specified TemporalAccessor object.
public static LocalTime from(TemporalAccessor temporal)
Parameters: This method accepts a single parameter temporal which is the temporal object. It should not be null.
Return value: This method returns the local time from temporal object, not null
Exception: This method throws a DateTimeException if unable to convert to a LocalTime.
Below programs illustrate the from() method:
LocalTime value : 06:17:32.760
LocalTime value : 06:17:35.131
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.