<legend id='5l9zH'><style id='5l9zH'><dir id='5l9zH'><q id='5l9zH'></q></dir></style></legend>
  • <i id='5l9zH'><tr id='5l9zH'><dt id='5l9zH'><q id='5l9zH'><span id='5l9zH'><b id='5l9zH'><form id='5l9zH'><ins id='5l9zH'></ins><ul id='5l9zH'></ul><sub id='5l9zH'></sub></form><legend id='5l9zH'></legend><bdo id='5l9zH'><pre id='5l9zH'><center id='5l9zH'></center></pre></bdo></b><th id='5l9zH'></th></span></q></dt></tr></i><div id='5l9zH'><tfoot id='5l9zH'></tfoot><dl id='5l9zH'><fieldset id='5l9zH'></fieldset></dl></div>

    1. <small id='5l9zH'></small><noframes id='5l9zH'>

      • <bdo id='5l9zH'></bdo><ul id='5l9zH'></ul>

        <tfoot id='5l9zH'></tfoot>

      1. 如何知道现在时间是否在两个小时之间?

        时间:2023-09-29
        <tfoot id='xh1hJ'></tfoot>
      2. <i id='xh1hJ'><tr id='xh1hJ'><dt id='xh1hJ'><q id='xh1hJ'><span id='xh1hJ'><b id='xh1hJ'><form id='xh1hJ'><ins id='xh1hJ'></ins><ul id='xh1hJ'></ul><sub id='xh1hJ'></sub></form><legend id='xh1hJ'></legend><bdo id='xh1hJ'><pre id='xh1hJ'><center id='xh1hJ'></center></pre></bdo></b><th id='xh1hJ'></th></span></q></dt></tr></i><div id='xh1hJ'><tfoot id='xh1hJ'></tfoot><dl id='xh1hJ'><fieldset id='xh1hJ'></fieldset></dl></div>
      3. <small id='xh1hJ'></small><noframes id='xh1hJ'>

        <legend id='xh1hJ'><style id='xh1hJ'><dir id='xh1hJ'><q id='xh1hJ'></q></dir></style></legend>
          <tbody id='xh1hJ'></tbody>
          <bdo id='xh1hJ'></bdo><ul id='xh1hJ'></ul>

                  本文介绍了如何知道现在时间是否在两个小时之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我现在有时间:

                  new Date();
                  

                  我有一些小时常数,例如,238(晚上 11 点或 23:00、上午 8 点或 08:00).我怎么知道现在是两个小时常数之间的时间?

                  And I have some hour constants, for example, 23 and 8 (it's 11pm or 23:00, 8am or 08:00). How I can know is now time between it's two hour constants?

                  如果现在时间在两个小时之间,则需要运行一些程序代码或不运行,例如,如果已经是晚上并且不是早上,则不要运行一些代码.

                  这里的图片可以更好地解释:

                  Here the image to better explain:

                  静音模式不触发的某些情况:

                  00:00 20.06.13 - 23:00 20.06.13 // after 23.00 can loud!!
                  
                  23:00 20.06.13 - 15:00 20.06.13 // after 15.00 can loud!!
                  
                  01:00 20.06.13 - 08:00 20.06.13 // after 08.00 can loud!!
                  
                  21:00 20.06.13 - 08:00 20.06.13 // after 08.00 can loud!!
                  

                  推荐答案

                  试试这个

                      int from = 2300;
                      int to = 800;
                      Date date = new Date();
                      Calendar c = Calendar.getInstance();
                      c.setTime(date);
                      int t = c.get(Calendar.HOUR_OF_DAY) * 100 + c.get(Calendar.MINUTE);
                      boolean isBetween = to > from && t >= from && t <= to || to < from && (t >= from || t <= to);
                  

                  这篇关于如何知道现在时间是否在两个小时之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Java 中使用占位符进行字符串格式化(如在 下一篇:System.out.printf 与 System.out.format

                  相关文章

                  最新文章

                    <bdo id='cmfPz'></bdo><ul id='cmfPz'></ul>
                  <i id='cmfPz'><tr id='cmfPz'><dt id='cmfPz'><q id='cmfPz'><span id='cmfPz'><b id='cmfPz'><form id='cmfPz'><ins id='cmfPz'></ins><ul id='cmfPz'></ul><sub id='cmfPz'></sub></form><legend id='cmfPz'></legend><bdo id='cmfPz'><pre id='cmfPz'><center id='cmfPz'></center></pre></bdo></b><th id='cmfPz'></th></span></q></dt></tr></i><div id='cmfPz'><tfoot id='cmfPz'></tfoot><dl id='cmfPz'><fieldset id='cmfPz'></fieldset></dl></div>

                    1. <legend id='cmfPz'><style id='cmfPz'><dir id='cmfPz'><q id='cmfPz'></q></dir></style></legend>

                      <tfoot id='cmfPz'></tfoot>

                      <small id='cmfPz'></small><noframes id='cmfPz'>