Java Date Time Java Java API
java.time.Year
public YearMonth atMonth(Month month)
The method combines the copy of this year object with the specified month to create a YearMonth.
YearMonth
public YearMonth atMonth(int month)
The method combines the copy of this year object with the specified value of month int to create a YearMonth.
package com.logicbig.example.year;import java.time.Year;import java.time.YearMonth;public class AtMonthExample { public static void main(String... args) { Year y = Year.of(2011); System.out.println(y); YearMonth ym = y.atMonth(10); System.out.println(ym); }}
20112011-10
package com.logicbig.example.year;import java.time.Month;import java.time.Year;import java.time.YearMonth;public class AtMonthExample2 { public static void main(String... args) { Year y = Year.of(2011); System.out.println(y); YearMonth ym = y.atMonth(Month.SEPTEMBER); System.out.println(ym); }}
20112011-09