Java Program to get the number of minutes in this duration


At first, set the Duration:

Duration duration = Duration.ofHours(10);

Now, get the number of minutes from the above Duration that has 10 hours:

d1.toMinutes()

Example

import java.time.Duration;
public class Demo {
   public static void main(String[] args) {
      Duration d1 = Duration.ofDays(25);
      Duration d2 = Duration.ofHours(10);
      System.out.println("Minutes in 25 days = "+d1.toMinutes());
      System.out.println("Minutes in 10 hours = "+d2.toMinutes());
   }
}

Output

Minutes in 25 days = 36000
Minutes in 10 hours = 600

Updated on: 30-Jul-2019

164 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements