Java Date Time Java Java API
Class:
java.time.Year
Methods:
public YearMonth atMonth(Month month)
The method combines the copy of this year object with the specified month to create a 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 .
Examples
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); } }
Output2011 2011-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); } }
Output2011 2011-09
|