Java Date Time - LocalDate now(Clock clock) example








LocalDate now(Clock clock) creates the current date from the specified clock.

Syntax

now has the following syntax.

public static LocalDate now(Clock clock)

Example

The following example shows how to use now.

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

The code above generates the following result.