Java Convert Number of Hours to Minutes

Tags: Java Duration Java 8

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

How to convert number of hours to minutes in Java

In Java, with a given number of hours we can use the Duration.toMinutes() to convert it to minutes value as the following Java code.

ConvertHoursToMinutesExample.java

import java.time.Duration;

public class ConvertHoursToMinutesExample {
    public static void main(String... args) {
        long numberOfHours = 3;

        // Convert Number of Hours to Minutes
        long numberOfMinutes = Duration.ofHours(numberOfHours).toMinutes();

        System.out.println("Number of hours: " + numberOfHours);
        System.out.println("Number of minutes: " + numberOfMinutes);
    }
}
The output as below.
Number of hours: 3
Number of minutes: 180

Happy Coding 😊

Java Convert Number of Days to Nanoseconds

Java Convert Number of Hours to Seconds

Java Convert Number of Hours to Milliseconds

Java Convert Number of Hours to Nanoseconds

Java Convert Number of Minutes to Seconds

Java Convert Number of Minutes to Milliseconds

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