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.


getLong has the following syntax.

public long getLong(TemporalField field)


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 =;
    long n = m.getLong(ChronoField.MONTH_OF_YEAR);


The code above generates the following result.