gpt4 book ai didi

java - HOUR_OF_DAY 的范围是多少?

转载 作者:IT老高 更新时间:2023-10-28 23:37:58 27 4
gpt4 key购买 nike

一个简单的问题,但我找不到它:

HOUR_OF_DAY 的范围是 0 到 23,还是 1 到 24?

我想要一个随机的 HOUR_OF_DAY,我需要吗:

        int randomHour = (int) (Math.random()*24);

        int randomHour = (int) (Math.random()*24+1);

最佳答案

来自 the documentation :

Field number for get and set indicating the hour of the day. HOUR_OF_DAY is used for the 24-hour clock. E.g., at 10:04:15.250 PM the HOUR_OF_DAY is 22.

如果晚上 10:04:15.250 是 HOUR_OF_DAY 22,则范围为 0 - 23。如果是 124,晚上 10 点。将是 23 岁。这在很多层面上都是错误的。 :-)

关于java - HOUR_OF_DAY 的范围是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23168805/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com