Close

Java Date Time - MonthDay.with() 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 with(Month month)

Returns a copy of this MonthDay with the month-of-year replaced with the corresponding field value of the provided Month.


Examples


package com.logicbig.example.monthday;

import java.time.Month;
import java.time.MonthDay;

public class WithExample {

public static void main(String... args) {

MonthDay m = MonthDay.now();
System.out.println(m);

MonthDay m2 = m.with(Month.JANUARY);
System.out.println(m2);
}
}

Output

--05-01
--01-01




See Also