@Test public void m15InstantsAreInSameTimeFrameWhenTheyAreInTheSame15MinuteFrame() { final M15 cut = new M15(); final LocalDate someDay = LocalDate.of(2015, Month.SEPTEMBER, 11); assertThat(cut.areInSameTimeFrame(someDay.atTime(20, 14, 59, 99999).toInstant(UTC), someDay.atTime(20, 0, 0, 0).toInstant(UTC))).isTrue(); assertThat(cut.areInSameTimeFrame(someDay.atTime(15, 2, 32, 0).toInstant(UTC), someDay.atTime(15, 13, 12, 653).toInstant(UTC))).isTrue(); assertThat(cut.areInSameTimeFrame(someDay.atTime(20, 0, 0, 0).toInstant(UTC), someDay.atTime(20, 15, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(someDay.atTime(14, 1, 0, 0).toInstant(UTC), someDay.plusDays(1).atTime(14, 1, 0, 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() % 15); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(15).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }
M15 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() % 15); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(15).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); } }
M15 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() % 15); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(15).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }  }
M15 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() % 15); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(15).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); }
M15 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() % 15); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(15).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);  }