PeriodUtil { public static int getPrecision(final long duration, int pointsRequired) { final double durationLog = Math.log10(duration); final double pointLog = Math.log10(pointsRequired); return (int) (durationLog - pointLog); } private  PeriodUtil(); static Period createToDateWithOffset(final long to, final int days); static Period createYearPeriod(final Integer year); static Period createYearMonthPeriod(final Integer year, final Integer month); static Period createYearMonthDayPeriod(final Integer year, final Integer month, final Integer day); static long createDate(final Integer year, final Integer month, final Integer day); static int getPrecision(final long duration, int pointsRequired);  }
@Test void testGetPrecision() { assertThat(PeriodUtil.getPrecision(new Period(0L, 100L).duration(), 100)).isEqualTo(0); assertThat(PeriodUtil.getPrecision(new Period(0L, 100L).duration(), 10)).isEqualTo(1); }