Java Date Time - MonthDay get(TemporalField field) example








MonthDay get(TemporalField field) gets the value of the specified field from this month-day as an int.

Syntax

get has the following syntax.

public int get(TemporalField field)

Example

The following example shows how to use get.

import java.time.MonthDay;
import java.time.temporal.ChronoField;
//  w  w w.j ava2  s  .  c o m
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.now();
    long n = m.get(ChronoField.MONTH_OF_YEAR);
    System.out.println(n);

  }
}

The code above generates the following result.