什么是HOUR_OF_DAY的范围? [英] what is the range of HOUR_OF_DAY?

查看:1395
本文介绍了什么是HOUR_OF_DAY的范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个简单的问题,但我无法找到它:

时HOUR_OF_DAY的0至23,或1和24之间的范围内

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

  INT randomHour =(INT)(的Math.random()* 24);

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


解决方案

从的文档


  

有关获取设置指示一天中的小时数场和。 HOUR_OF_DAY 用于24小时制。例如,在10:04:15.250 PM的 HOUR_OF_DAY 22


如果10:04:15.250 PM是 HOUR_OF_DAY 22,这将使范围 0 - 23 。如果是 1 24 10时是23,这将是错误的这么多层次。 : - )

A simple question, but i couldn't find it:

Is the range of HOUR_OF_DAY between 0 and 23, or 1 and 24?

I want a random HOUR_OF_DAY, do I need:

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

or

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

解决方案

From 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.

If 10:04:15.250 PM is HOUR_OF_DAY 22, That would make the range 0 - 23. If it were 1 to 24, 10 p.m. would be 23. And that would be wrong on so many levels. :-)

这篇关于什么是HOUR_OF_DAY的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆