Period extends Range<Long> { public int getPrecision(int pointsRequired) { if (!isBounded()) { return 0; } if (pointsRequired == 0) { return 0; } long duration = getTo() - getFrom(); long scale = duration / pointsRequired; return (int) Math.log10(scale); } Period();  Period(final Long fromMs, final Long toMs);  Period(final Instant from, final Instant to); static final Period clone(Period period); static Comparator<Period> comparingByFromTime(); static Comparator<Period> comparingByToTime(); static final Period createMsPeriod(final long fromMs); static final Period createNullPeriod(); Period doublePeriod(); Long getHoursInPeriod(); int getPrecision(int pointsRequired); Long getDaysInPeriod(); Long getFromMs(); Optional<Instant> getFromTime(); void setFromMs(Long from); Long getToMs(); Optional<Instant> getToTime(); void setToMs(Long to); String getDurationStr(); Long duration(); @Override String toString();  }
@Test void testPrecision() { assertThat(new Period(0L, 1000L).getPrecision(1)).isEqualTo(3); assertThat(PeriodUtil.createYearPeriod(2013).getPrecision(1000)).isEqualTo(7); }