MonthDay with(Month month)
returns a
copy of this MonthDay with the month-of-year altered.
with
has the following syntax.
public MonthDay with(Month month)
The following example shows how to use with
.
import java.time.Month; import java.time.MonthDay; //w w w . ja v a2 s . c om public class Main { public static void main(String[] args) { MonthDay m = MonthDay.now(); MonthDay n = m.with(Month.JANUARY); System.out.println(n); } }
The code above generates the following result.