Example usage for java.time Duration dividedBy

List of usage examples for java.time Duration dividedBy

Introduction

In this page you can find the example usage for java.time Duration dividedBy.

Prototype

public long dividedBy(Duration divisor) 

Source Link

Document

Returns number of whole times a specified Duration occurs within this Duration.

Usage

From source file:Main.java

public static void main(String[] args) {
    Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON);
    System.out.println(duration.getSeconds());

    duration = duration.dividedBy(2);

    System.out.println(duration.getSeconds());

}

From source file:ddf.content.plugin.video.VideoThumbnailPlugin.java

private byte[] createGifThumbnailWithDuration(final String videoFilePath, final Duration duration)
        throws IOException, InterruptedException {
    final Duration durationFraction = duration.dividedBy(THUMBNAIL_COUNT);

    // Start numbering files with 1 to match FFmpeg's convention.
    for (int clipNum = FFMPEG_FILE_NUMBERING_START; clipNum <= THUMBNAIL_COUNT; ++clipNum) {
        final String thumbnailPath = String.format(getThumbnailFilePath(), clipNum);

        final String seek = durationToString(durationFraction.multipliedBy(clipNum - 1));

        final CommandLine command = getFFmpegCreateThumbnailCommand(videoFilePath, thumbnailPath, seek, 1);

        final DefaultExecuteResultHandler resultHandler = executeFFmpeg(command, 15, null);
        resultHandler.waitFor();/*from w  w w.  j a  v a2 s  .  com*/
    }

    return createGifFromThumbnailFiles();
}

From source file:com.drunkendev.io.recurse.tests.RecursionTest.java

/**
 * Used to perform a timed average of a repeated set of runs.
 *
 * @param   count/*www  . j a v a2s . com*/
 *          Amount of times to run {@code r}.
 * @param   r
 *          {@link Runnable} object to perform tests against.
 */
public void averageTest(int count, Runnable r) {
    Duration total = Duration.ZERO;
    for (int i = 0; i < count; i++) {
        total = total.plus(time(() -> r.run()));
    }
    System.out.format("%nAverage duration: %s%n%n", total.dividedBy(count));
}