Java Date Time Java Java API
java.time.YearMonth
public YearMonth withMonth(int month)
Returns a copy of this YearMonth with the month-of-year replaced by the the specified month.
YearMonth
package com.logicbig.example.yearmonth;import java.time.YearMonth;public class WithMonthExample { public static void main(String... args) { YearMonth y = YearMonth.of(2010, 11); System.out.println(y); YearMonth y2 = y.withMonth(12); System.out.println(y2); }}
2010-112010-12