@Test public void m5InstantsAreInSameTimeFrameWhenTheyAreInTheSame5MinuteFrame() { final M5 cut = new M5(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2014, Month.JULY, 7).atTime(20, 4, 59, 99999).toInstant(UTC), LocalDate.of(2014, Month.JULY, 7).atTime(20, 0, 0, 0).toInstant(UTC))).isTrue(); assertThat(cut.areInSameTimeFrame(LocalDate.of(1951, Month.NOVEMBER, 15).atTime(15, 5, 32, 0).toInstant(UTC), LocalDate.of(1951, Month.NOVEMBER, 15).atTime(15, 7, 12, 653).toInstant(UTC))).isTrue(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2014, Month.JULY, 7).atTime(20, 0, 0, 0).toInstant(UTC), LocalDate.of(2014, Month.JULY, 7).atTime(20, 5, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2341, Month.OCTOBER, 24).atTime(14, 1, 0, 0).toInstant(UTC), LocalDate.of(2341, Month.OCTOBER, 25).atTime(14, 1, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2003, Month.DECEMBER, 24).atTime(17, 14, 0, 0).toInstant(UTC), LocalDate.of(2006, Month.DECEMBER, 24).atTime(17, 14, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(LocalDate.of(1298, Month.FEBRUARY, 10).atTime(12, 15, 21, 0).toInstant(UTC), LocalDate.of(1298, Month.JANUARY, 10).atTime(12, 15, 21, 0).toInstant(UTC))).isFalse(); }
@Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0); final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(5).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }
M5 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0); final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(5).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); } }
M5 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0); final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(5).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }  }
M5 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0); final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(5).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }  @Override Instant instantOfNextFrame(final Instant current); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2); }
M5 implements TimeFrame { @Override public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) { final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0); final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(5).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }  @Override Instant instantOfNextFrame(final Instant current); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2);  }