Java Date Time - YearMonth now(ZoneId zone) example








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

Syntax

now has the following syntax.

public static YearMonth now(ZoneId zone)

Example

The following example shows how to use now.

import java.time.YearMonth;
import java.time.ZoneId;
//from   w  w  w .j  a  va2 s. co  m
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.now(ZoneId.systemDefault());
    
    System.out.println(y);

  }
}

The code above generates the following result.