Java Date Time - LocalDateTime from(TemporalAccessor temporal) example








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

Syntax

from has the following syntax.

public static LocalDateTime from(TemporalAccessor temporal)

Example

The following example shows how to use from.

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

The code above generates the following result.