Java 8 Date and Time Time Field

I am navigating through the Java 8 Date and Time new APIs, and I could not go further, and I cannot find any good resource on the net. I hope you are fueling this question.

My simple source code

final LocalDate date = LocalDate.now();
date.get(TemporalField field)

And I get the source code, and I see.

public int get(TemporalField field)
  Gets the value of the specified field from this date as an int.

My question is how can I get TemporalField or is this the easiest way to get this code to work.

final int value = date.get(????);

It works thanks to JB Nizet

date.get(java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH);

API

http://docs.oracle.com/javase/8/docs/api/java/time/temporal/ChronoField.html
+4
source share
2 answers

There are several ways to get instances TemporalField.

First, enum ChronoFieldimplements TemporalFieldand contains various constants.

ChronoField.ALIGNED_WEEK_OF_YEAR;

-, IsoFields JulianFields TemporalField.

IsoFields.QUARTER_OF_YEAR;
JulianFields.JULIAN_DAY;

-, WeekFields TemporalField TemporalField, WeekFields.

WeekFields.WEEK_BASED_YEARS;
WeekFields.SUNDAY_START.weekOfMonth();
+7

Javadoc of TemporalField , :

" ChronoField. IsoFields, WeekFields JulianFields. , ."

, .

+5

All Articles