@Test public void testFormat() { assertThat(generator.format(0)).isEqualTo("00:00:00.000"); assertThat(generator.format(123_456_789)).isEqualTo("34:17:36.789"); }
String format(@Nonnegative int milliseconds) { if (milliseconds < 0) { throw new IllegalArgumentException("milliseconds should be positive number, but it was " + milliseconds); } long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60; long minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60; long hours = TimeUnit.MILLISECONDS.toHours(milliseconds); return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds % 1_000); }
ThumbnailGeneratorFFmpeg implements ThumbnailGenerator { String format(@Nonnegative int milliseconds) { if (milliseconds < 0) { throw new IllegalArgumentException("milliseconds should be positive number, but it was " + milliseconds); } long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60; long minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60; long hours = TimeUnit.MILLISECONDS.toHours(milliseconds); return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds % 1_000); } }
ThumbnailGeneratorFFmpeg implements ThumbnailGenerator { String format(@Nonnegative int milliseconds) { if (milliseconds < 0) { throw new IllegalArgumentException("milliseconds should be positive number, but it was " + milliseconds); } long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60; long minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60; long hours = TimeUnit.MILLISECONDS.toHours(milliseconds); return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds % 1_000); }  }
ThumbnailGeneratorFFmpeg implements ThumbnailGenerator { String format(@Nonnegative int milliseconds) { if (milliseconds < 0) { throw new IllegalArgumentException("milliseconds should be positive number, but it was " + milliseconds); } long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60; long minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60; long hours = TimeUnit.MILLISECONDS.toHours(milliseconds); return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds % 1_000); }  @Override Single<File> generate(File video, int milliseconds); }
ThumbnailGeneratorFFmpeg implements ThumbnailGenerator { String format(@Nonnegative int milliseconds) { if (milliseconds < 0) { throw new IllegalArgumentException("milliseconds should be positive number, but it was " + milliseconds); } long seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60; long minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60; long hours = TimeUnit.MILLISECONDS.toHours(milliseconds); return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds % 1_000); }  @Override Single<File> generate(File video, int milliseconds);  }