Java Date Time - OffsetDateTime toLocalTime() example








OffsetDateTime toLocalTime() gets the LocalTime part of this date-time.

Syntax

toLocalTime has the following syntax.

public LocalTime toLocalTime()

Example

The following example shows how to use toLocalTime.

import java.time.LocalTime;
import java.time.OffsetDateTime;
/*from   w ww  . j  a  v a 2s . c o  m*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    LocalTime l = o.toLocalTime();
    System.out.println(l);
  }
}

The code above generates the following result.