Java Date Time - MonthDay getLong(TemporalField field) example








MonthDay getLong(TemporalField field) gets the value of the specified field from this month-day as a long.

Syntax

getLong has the following syntax.

public long getLong(TemporalField field)

Example

The following example shows how to use getLong.

import java.time.MonthDay;
import java.time.temporal.ChronoField;
/*from w w w  .  j  a  v  a  2s. co m*/
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.now();
    long n = m.getLong(ChronoField.MONTH_OF_YEAR);
    System.out.println(n);

  }
}

The code above generates the following result.