Java Program to get the number of minutes in this duration

Java 8Object Oriented ProgrammingProgramming

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
raja
Published on 24-Apr-2019 15:15:40
Advertisements