LocalDateTime of(LocalDate date, LocalTime time) example

Description

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 . j av  a2 s .c o m*/
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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset