Java中的LocalTime ofSecondOfDay()方法
可以使用ofSecondOfDay()Java中LocalTime类中的方法使用一天中的几秒钟来获取LocalTime对象。此方法需要一个参数,即一天中的秒,它返回一天中的秒的LocalTime对象。
演示此程序如下
示例
import java.time.*;
public class Demo {
public static void main(String[] args) {
long seconds = 18930;
System.out.println("The seconds of the day: " + seconds);
System.out.println("The LocalTime is: " + LocalTime.ofSecondOfDay(seconds));
}
}输出
The seconds of the day: 18930 The LocalTime is: 05:15:30
现在让我们了解上面的程序。
首先显示一天中的秒。然后使用该ofSecondOfDay()方法使用一天中的秒数获取LocalTime对象并进行打印。演示此的代码片段如下:
long seconds = 18930;
System.out.println("The seconds of the day: " + seconds);
System.out.println("The LocalTime is: " + LocalTime.ofSecondOfDay(seconds));热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短