LocalDateTime toLocalTime() example

Description

LocalDateTime 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.LocalDateTime;
/*w  w w.  ja  v a  2s  . c o  m*/
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);
    
    System.out.println(a.toLocalTime());
  }
}

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