MonthDay with(Month month) example

Description

MonthDay with(Month month) returns a copy of this MonthDay with the month-of-year altered.

Syntax

with has the following syntax.


public MonthDay with(Month month)

Example

The following example shows how to use with.


import java.time.Month;
import java.time.MonthDay;
//from   www.j a v a2s.  com
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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset