Java Convert Number of Minutes to Milliseconds

Tags: Java Duration Java 8

In this Java tutorial we learn how to convert a number of minutes to number of milliseconds using the java.time.Duration class in Java programming language.

How to convert number of minutes to milliseconds in Java

In Java, with a given number of minutes we can use the Duration.toMillis() method to convert it to number of milliseconds as the following Java program.

ConvertMinutesToMillisecondsExample.java

import java.time.Duration;

public class ConvertMinutesToMillisecondsExample {
    public static void main(String... args) {
        long numberOfMinutes = 2;

        // Convert Number of Minutes to Milliseconds
        long numberOfMilliseconds = Duration.ofMinutes(numberOfMinutes).toMillis();

        System.out.println("Number of minutes: " + numberOfMinutes);
        System.out.println("Number of milliseconds: " + numberOfMilliseconds);
    }
}
The output as below.
Number of minutes: 2
Number of milliseconds: 120000

Happy Coding 😊

Java Convert Number of Minutes to Seconds

Java Convert Number of Minutes to Nanoseconds

Java Convert Number of Seconds to Milliseconds

Java Convert Number of Seconds to Nanoseconds

Java Convert Number of Milliseconds to Nanoseconds

Java Convert Number of Days to Nanoseconds

Java Convert Number of Hours to Minutes

Java Convert Number of Hours to Seconds

Java Convert Number of Hours to Milliseconds

Java Convert Number of Hours to Nanoseconds