ZonedDateTime get(TemporalField field)
gets the value of the specified field from this date-time as an int
get
has the following syntax.
public int get(TemporalField field)
The following example shows how to use get
.
import java.time.ZonedDateTime; import java.time.temporal.ChronoField; //from ww w .j ava 2 s . c o m public class Main { public static void main(String[] args) { ZonedDateTime dateTime =ZonedDateTime.now(); System.out.println(dateTime.get(ChronoField.YEAR)); } }
The code above generates the following result.