Java Date Time - OffsetDateTime toZonedDateTime() example








OffsetDateTime toZonedDateTime() converts this date-time to a ZonedDateTime using the offset as the zone ID.

Syntax

toZonedDateTime has the following syntax.

public ZonedDateTime toZonedDateTime()

Example

The following example shows how to use toZonedDateTime.

import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
/*w  ww  .ja  va 2s  .c  o m*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.MAX;
    ZonedDateTime z= o.toZonedDateTime();
    System.out.println(z);
  }
}

The code above generates the following result.