@Test public void m15InstantOfNextFrameShouldReturnTheNextInstantWhereTheMinutesAreAMultipleOf15() { final M15 cut = new M15(); final LocalDate someDay = LocalDate.of(2015, Month.SEPTEMBER, 11); assertThat(cut.instantOfNextFrame(someDay.atTime(20, 4, 0, 0).toInstant(UTC))) .isEqualTo(someDay.atTime(20, 15, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(someDay.atTime(15, 59, 0, 0).toInstant(UTC))) .isEqualTo(someDay.atTime(16, 0, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(someDay.atTime(17, 29, 0, 0).toInstant(UTC))) .isEqualTo(someDay.atTime(17, 30, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(someDay.atTime(23, 14, 59, 99999).toInstant(UTC))) .isEqualTo(someDay.atTime(23, 15, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(someDay.atTime(23, 53, 25, 82).toInstant(UTC))) .isEqualTo(someDay.plusDays(1).atTime(0, 0, 0, 0).toInstant(UTC)); }
@Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(15 - (minutes % 15)).toInstant(); }
M15 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(15 - (minutes % 15)).toInstant(); } }
M15 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(15 - (minutes % 15)).toInstant(); }  }
M15 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(15 - (minutes % 15)).toInstant(); }  @Override Instant instantOfNextFrame(final Instant current); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2); }
M15 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant current) { final OffsetDateTime time = current.atOffset(UTC); final int minutes = time.get(MINUTE_OF_HOUR); return time.withSecond(0).withNano(0).plusMinutes(15 - (minutes % 15)).toInstant(); }  @Override Instant instantOfNextFrame(final Instant current); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2);  }