Period.get(TemporalUnit) only works when passed ChronoUnit.YEARS, ChronoUnit.MONTHS, or ChronoUnit.DAYS. All other values are guaranteed to throw an UnsupportedTemporalTypeException.
Suppress false positives by adding the suppression annotation @SuppressWarnings("PeriodGetTemporalUnit") to the enclosing element.