Close

Java Date Time - MonthDay.withMonth() Examples

Java Date Time Java Java API 


Class:

java.time.MonthDay

java.lang.Objectjava.lang.Objectjava.time.MonthDayjava.time.MonthDayjava.time.temporal.TemporalAccessorTemporalAccessorjava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public MonthDay withMonth(int month)

Returns a copy of this MonthDay with the month-of-year replaced with the provided month value


Examples


package com.logicbig.example.monthday;

import java.time.MonthDay;

public class WithMonthExample {

public static void main(String... args) {
MonthDay m = MonthDay.of(4, 10);
System.out.println(m);

MonthDay m2 = m.withMonth(12);
System.out.println(m2);
}
}

Output

--04-10
--12-10




See Also