Java Date Time Java Java API
Class:
java.time.YearMonth
Methods:
public static YearMonth of(int year,
Month month)
Obtains an instance of YearMonth from specified int year and Month values.
public static YearMonth of(int year,
int month)
Obtains an instance of YearMonth from specified int year and int month values.
Examples
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); } }
Output2010-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); } }
Output2005-04
|