LocalTime from(TemporalAccessor temporal) example

Description

LocalTime from(TemporalAccessor temporal) gets an instance of LocalTime from a temporal object.

Syntax

from has the following syntax.


public static LocalTime from(TemporalAccessor temporal)

Example

The following example shows how to use from.


import java.time.LocalDateTime;
import java.time.LocalTime;
/*from   w w w .  j  a v  a  2s .  co  m*/
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.from(LocalDateTime.now());
    
    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