Year atMonth(Month month) example

Description

Year atMonth(Month month) combines this year with a month to create a YearMonth.

Syntax

atMonth has the following syntax.


public YearMonth atMonth(Month month)

Example

The following example shows how to use atMonth.


import java.time.Month;
import java.time.Year;
import java.time.YearMonth;
/*from   w  w w.j  a v a2s  .  com*/
public class Main {
  public static void main(String[] args) {
    Year y = Year.of(2014);
    YearMonth l = y.atMonth(Month.JANUARY);
    System.out.println(l);

  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset