@Test public void m30InstantsAreInSameTimeFrameWhenTheyAreInTheSame30MinuteFrame() { final M30 cut = new M30(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2041, Month.FEBRUARY, 7).atTime(0, 29, 59, 99999).toInstant(UTC), LocalDate.of(2041, Month.FEBRUARY, 7).atTime(0, 0, 0, 0).toInstant(UTC))).isTrue(); assertThat( cut.areInSameTimeFrame(LocalDate.of(1752, Month.NOVEMBER, 15).atTime(21, 53, 59, 9231).toInstant(UTC), LocalDate.of(1752, Month.NOVEMBER, 15).atTime(21, 35, 34, 1234).toInstant(UTC))).isTrue(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2041, Month.FEBRUARY, 7).atTime(0, 0, 0, 0).toInstant(UTC), LocalDate.of(2041, Month.FEBRUARY, 7).atTime(0, 30, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2570, Month.NOVEMBER, 24).atTime(15, 47, 0, 0).toInstant(UTC), LocalDate.of(2570, Month.NOVEMBER, 25).atTime(15, 47, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2501, Month.JANUARY, 24).atTime(20, 29, 0, 0).toInstant(UTC), LocalDate.of(1892, Month.JANUARY, 24).atTime(20, 29, 0, 0).toInstant(UTC))).isFalse(); assertThat(cut.areInSameTimeFrame(LocalDate.of(2013, Month.JANUARY, 10).atTime(9, 0, 57, 0).toInstant(UTC), LocalDate.of(2013, Month.OCTOBER, 10).atTime(9, 0, 57, 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() % 30); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(30).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }
M30 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() % 30); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(30).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); } }
M30 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() % 30); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(30).toInstant(); return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext)); }  }
M30 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() % 30); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(30).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); }
M30 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() % 30); final Instant start = localStart.toInstant(); final Instant startOfNext = localStart.plusMinutes(30).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);  }