Java Date Time - MonthDay from(TemporalAccessor temporal) example








MonthDay from(TemporalAccessor temporal) creates an instance of MonthDay from a temporal object. The conversion extracts the MONTH_OF_YEAR and DAY_OF_MONTH fields.

Syntax

from has the following syntax.

public static MonthDay from(TemporalAccessor temporal)

Example

The following example shows how to use from.

import java.time.LocalDate;
import java.time.MonthDay;
/*  w w  w.ja  v a  2 s .  c  o  m*/
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.from(LocalDate.now());

    System.out.println(m);

  }
}

The code above generates the following result.