Java Date Time - Year now(ZoneId zone) example








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

Syntax

now has the following syntax.

public static Year now(ZoneId zone)

Example

The following example shows how to use now.

import java.time.Year;
import java.time.ZoneId;
//  w  w  w .  j  av  a 2s.  com
public class Main {
  public static void main(String[] args) {
    Year y = Year.now(ZoneId.systemDefault());
    System.out.println(y);

  }
}

The code above generates the following result.