Java Date Time - LocalDateTime of(LocalDate date, LocalTime time) example








LocalDateTime of(LocalDate date, LocalTime time) gets an instance of LocalDateTime from a date and time.

Syntax

of has the following syntax.

public static LocalDateTime of(LocalDate date,   LocalTime time)

Example

The following example shows how to use of.

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
//from   ww  w . jav a2s. c om
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(LocalDate.now(),LocalTime.NOON);
    
    System.out.println(a);
  }
}

The code above generates the following result.