Java Date Time - Year now() example








Year now() creates the current year from the system clock in the default time-zone.

Syntax

now has the following syntax.

public static Year now()

Example

The following example shows how to use now.

import java.time.Year;

public class Main {
  public static void main(String[] args) {
    Year y = Year.now();
    System.out.println(y);

  }
}

The code above generates the following result.