This example uses a custom TemporalQuery to find the quarter of year for a given date. Implementing the TemporalQuery interface with the queryFrom(TemporalAccessor) method allows for a way to extract information from a temporal object. The queryFrom method compares the passed-in date against the ChronoField.MONTHOFYEAR then returning the appropriate quarter of year.
Note: This example is purely for demonstration as the java 8 time api provides YearMonth.from(temporal).get(IsoFields.QUARTER_OF_YEAR) to get the current quarter of year.