Java Date Time - OffsetDateTime of(LocalDate date, LocalTime time, ZoneOffset offset) example








OffsetDateTime of(LocalDate date, LocalTime time, ZoneOffset offset) Obtains an instance of OffsetDateTime from a date, time and offset.

Syntax

of has the following syntax.

public static OffsetDateTime of(LocalDate date,   LocalTime time,   ZoneOffset offset)

Example

The following example shows how to use of.

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
/*w w w.  j av a  2  s .c om*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.of(LocalDate.now(),LocalTime.NOON, ZoneOffset.UTC);
    
    System.out.println(o);
  }
}

The code above generates the following result.