LocalDateTime of(date, time) method in Java with Examples
The of(LocalDate date, LocalTime time) method of LocalDateTime class in Java is used to obtain an instance of LocalDateTime using the two input parameters, date and time. Initially, two separate instances are created. One is of LocalDate type and the other one is of LocalTime type. Then these are merged to create a LocalDateTime.
public static LocalDateTime of(LocalDate date, LocalTime time)
Parameters: This method accepts two parameters:
- date– It is of LocalDate type and represents the local date.
- time– It is of LocalTime type and represents the local time.
Return Value: This method returns the localdate-time.
Exceptions: This method does not throw any exception.
Below programs illustrate the of(LocalDate date, LocalTime time) method in Java:
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.