// ----------------------------------------------------------------------- // query(TemporalQuery) // ----------------------------------------------------------------------- @Test public void test_query() { assertEquals(Month.JUNE.query(TemporalQueries.chronology()), IsoChronology.INSTANCE); assertEquals(Month.JUNE.query(TemporalQueries.localDate()), null); assertEquals(Month.JUNE.query(TemporalQueries.localTime()), null); assertEquals(Month.JUNE.query(TemporalQueries.offset()), null); assertEquals(Month.JUNE.query(TemporalQueries.precision()), ChronoUnit.MONTHS); assertEquals(Month.JUNE.query(TemporalQueries.zone()), null); assertEquals(Month.JUNE.query(TemporalQueries.zoneId()), null); }
@SuppressWarnings("unchecked") @Override public <R> R query(TemporalQuery<R> query) { if (query == TemporalQueries.precision()) { return (R) ChronoUnit.ERAS; } if (query == TemporalQueries.chronology() || query == TemporalQueries.zone() || query == TemporalQueries.zoneId() || query == TemporalQueries.offset() || query == TemporalQueries.localDate() || query == TemporalQueries.localTime()) { return null; } return query.queryFrom(this); }