Java Date Time - YearMonth atEndOfMonth() example








YearMonth atEndOfMonth() returns a LocalDate at the end of the month.

Syntax

atEndOfMonth has the following syntax.

public LocalDate atEndOfMonth()

Example

The following example shows how to use atEndOfMonth.

import java.time.LocalDate;
import java.time.YearMonth;
// www  .ja  va  2  s .com
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    LocalDate l = y.atEndOfMonth();
    System.out.println(l);

  }
}

The code above generates the following result.