Java Date Time - LocalTime from(TemporalAccessor temporal) example








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  2 s  .  com
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.