MonthDay from(TemporalAccessor temporal) example

Description

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  va  2  s .  co  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.





















Home »
  Java Date Time »
    java.time Reference »




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