MonthDay withDayOfMonth(int dayOfMonth) example
Description
MonthDay withDayOfMonth(int dayOfMonth)
returns a copy of this MonthDay with the day-of-month altered.
Syntax
withDayOfMonth
has the following syntax.
public MonthDay withDayOfMonth(int dayOfMonth)
Example
The following example shows how to use withDayOfMonth
.
import java.time.MonthDay;
// w ww. j a va 2 s. c o m
public class Main {
public static void main(String[] args) {
MonthDay m = MonthDay.now();
MonthDay n = m.withDayOfMonth(21);
System.out.println(n);
}
}
The code above generates the following result.