TimePeriod { public Period getPeriod() { return Period.between( LocalDate.ofInstant(from, ZoneOffset.UTC), LocalDate.ofInstant(to, ZoneOffset.UTC)); } private  TimePeriod(final Instant from, final Instant to); static TimePeriod between(final Instant from, final Instant to); static TimePeriod fromEpochTo(final Instant to); static TimePeriod between(final long fromMs, final long toMs); Instant getFrom(); Instant getTo(); Period getPeriod(); Period getPeriod(final ZoneOffset zoneOffset); Duration getDuration(); String getDurationStr(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); static Comparator<TimePeriod> comparingByFromTime(); static Comparator<TimePeriod> comparingByToTime();  }
@Test void testGetPeriod() { final Instant now = Instant.now().truncatedTo(ChronoUnit.MILLIS); final Instant future = now.plus(2, ChronoUnit.DAYS); final TimePeriod period = TimePeriod.between(now, future); assertThat(now).isEqualTo(period.getFrom()); assertThat(future).isEqualTo(period.getTo()); assertThat(period.getPeriod()).isEqualTo(Period.ofDays(2)); }