Java Convert Minutes to Duration

Tags: Java Duration Java 8

In this Java core tutorial we learn how to convert a number of minutes to java.time.Duration object in Java programming language.

How to convert minutes to Duration in Java

In Java, we can use the Duration.ofMinutes(long minutes) static method to instantiate a Duration object from number of minutes as the example Java code below.

ConvertMinutesToDurationExample1.java

import java.time.Duration;

public class ConvertMinutesToDurationExample1 {
    public static void main(String... args) {
        long numberOfMinutes = 567;

        // Convert number of minutes to Duration
        Duration duration = Duration.ofMinutes(numberOfMinutes);

        System.out.println("Number of minutes: " + numberOfMinutes);
        System.out.println("Duration: " + duration);
    }
}
The output as below.
Number of minutes: 567
Duration: PT9H27M

Happy Coding 😊

Java Convert Days to Duration

Java Convert Hours to Duration

Java Convert Seconds to Duration

Java Convert Milliseconds to Duration

Java Convert Nanoseconds to Duration

Java Convert String to Duration

Java Convert Duration to Seconds