Java Date Time - LocalDate get(TemporalField field) example








LocalDate get(TemporalField field) gets the value of the specified field from this date 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.LocalDate;
import java.time.temporal.ChronoField;
//w  w w  .  jav  a  2  s.c  o  m
public class Main {
  public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);

    System.out.println(a.get(ChronoField.DAY_OF_YEAR));
  }
}

The code above generates the following result.