首先,设置持续时间:
Duration duration = Duration.ofHours(10);
现在,从上述持续时间中获取具有10小时的分钟数:
d1.toMinutes()
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()); } }
输出结果
Minutes in 25 days = 36000 Minutes in 10 hours = 600