Java Date Time - ZonedDateTime toOffsetDateTime() example

ZonedDateTime toOffsetDateTime() converts this date-time to an OffsetDateTime.


toOffsetDateTime has the following syntax.

public OffsetDateTime toOffsetDateTime()


The following example shows how to use toOffsetDateTime.

import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
// w  ww .  ja v  a 2 s  . c  om
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =;
    OffsetDateTime o =  dateTime.toOffsetDateTime();

The code above generates the following result.