Java Convert Number of Minutes to Seconds
Tags: Java Duration Java 8
In this Java tutorial we learn how to convert a number of minutes to seconds using the java.time.Duration class in Java programming language.
How to convert number of minutes to seconds in Java
In Java, with a given number of minutes we can use the Duration.toSeconds() method to convert it to seconds value as the following example Java code.
ConvertMinutesToSecondsExample.java
import java.time.Duration;
public class ConvertMinutesToSecondsExample {
public static void main(String... args) {
long numberOfMinutes = 60;
// Convert Number of Minutes to Seconds
long numberOfSeconds = Duration.ofMinutes(numberOfMinutes).toSeconds();
System.out.println("Number of minutes: " + numberOfMinutes);
System.out.println("Number of seconds: " + numberOfSeconds);
}
}
Number of minutes: 60
Number of seconds: 3600
Happy Coding 😊
Related Articles
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
Java Convert Number of Days to Nanoseconds
Java Convert Number of Hours to Minutes
Java Convert Number of Hours to Seconds