This example will show how to find the current quarter from a given date using java date and java 8 date time API TemporalQuery.
Straight up Java
Java 8 Date and Time API
Java 8 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.MONTH_OF_YEAR 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.