Java Date Time - LocalDateTime now(ZoneId zone) example








LocalDateTime now(ZoneId zone) gets the current date-time from the system clock in the specified time-zone.

Syntax

now has the following syntax.

public static LocalDateTime now(ZoneId zone)

Example

The following example shows how to use now.

import java.time.LocalDateTime;
import java.time.ZoneId;
/*www.ja  va2 s.  c  om*/
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.now(ZoneId.systemDefault());
    
    System.out.println(a);
  }
}

The code above generates the following result.