Java Date Time - OffsetDateTime toOffsetTime() example








OffsetDateTime toOffsetTime() converts this date-time to an OffsetTime.

Syntax

toOffsetTime has the following syntax.

public OffsetTime toOffsetTime()

Example

The following example shows how to use toOffsetTime.

import java.time.OffsetDateTime;
import java.time.OffsetTime;
//from   ww w .  ja  va 2  s. co m
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.MAX;
    OffsetTime of = o.toOffsetTime();
    System.out.println(of);
  }
}

The code above generates the following result.