将时间(本地时间)转换为秒[关闭]

问题描述 投票:0回答:0

我需要将所有小时/分钟/秒转换为秒的总和

LocalTime t1 = LocalTime.of(23, 0,10); // 82800 + 10
LocalTime t2 = LocalTime.of(23, 1,20); // 82800 + 60 + 20
LocalTime total = t1.plusHours(t2.getHour())
                         .plusMinutes(t2.getMinute())
                         .plusSeconds(t2.getSecond()); // 82810 + 82880 = 165690 seconds
    //total.toSecondOfDay()

我需要将所有小时/分钟/秒转换为秒的总和

java time java-time localtime seconds
© www.soinside.com 2019 - 2024. All rights reserved.