ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone) example

Description

ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone) creates an instance of ZonedDateTime from a local date and time.

Syntax

of has the following syntax.


public static ZonedDateTime of(LocalDate date,   LocalTime time,   ZoneId zone)

Example

The following example shows how to use of.


import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
/*  ww  w .  j  av a 2  s  . com*/
public class Main {
  public static void main(String[] args) {
    ZonedDateTime z = ZonedDateTime.of(LocalDate.now(),LocalTime.now(),ZoneId.systemDefault());
    
    System.out.println(z);

  }
}

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