Java Date Time - Year now(Clock clock) example








Year now(Clock clock) creates the current year from the specified clock.

Syntax

now has the following syntax.

public static Year now(Clock clock)

Example

The following example shows how to use now.

import java.time.Clock;
import java.time.Year;
/*from www .j av  a2s  .c  o m*/
public class Main {
  public static void main(String[] args) {
    Year y = Year.now(Clock.systemDefaultZone());
    System.out.println(y);

  }
}

The code above generates the following result.