OffsetDateTime toLocalDateTime() example

Description

OffsetDateTime toLocalDateTime() gets the LocalDateTime part of this offset date-time.

Syntax

toLocalDateTime has the following syntax.


public LocalDateTime toLocalDateTime()

Example

The following example shows how to use toLocalDateTime.


import java.time.LocalDateTime;
import java.time.OffsetDateTime;
//from  ww w .j  ava 2  s . c  om
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    LocalDateTime l = o.toLocalDateTime();
    System.out.println(l);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset