Java Date Time Java Java API
java.time.YearMonth
public static YearMonth of(int year, Month month)
Obtains an instance of YearMonth from specified int year and Month values.
YearMonth
public static YearMonth of(int year, int month)
Obtains an instance of YearMonth from specified int year and int month values.
package com.logicbig.example.yearmonth;import java.time.Month;import java.time.YearMonth;public class OfExample { public static void main(String... args) { YearMonth y = YearMonth.of(2010, Month.AUGUST); System.out.println(y); }}
2010-08
package com.logicbig.example.yearmonth;import java.time.YearMonth;public class OfExample2 { public static void main(String... args) { YearMonth y = YearMonth.of(2005, 4); System.out.println(y); }}
2005-04