The ofNanoOfDay() method of LocalTime class is used to obtain LocalTime Instance from a nanos-of-day value. This returns a LocalTime with the specified the nano of day, from 0 to 24 * 60 * 60 * 1, 000, 000, 000 – 1 passed as parameter.
public static LocalTime ofNanoOfDay(long nanoOfDay)
Parameters: This method accepts a single parameter nanoOfDay which is the nano of day, from 0 to 24 * 60 * 60 * 1, 000, 000, 000 – 1.
Return value: This method returns LocalTime instance created from the nanoOfDay passed as the parameter.
Exception: This method throws DateTimeException if the nanoofDay value passed as the parameter is invalid.
Below programs illustrate the ofNanoOfDay() method:
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.