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

    1. <small id='qXucx'></small><noframes id='qXucx'>

          <bdo id='qXucx'></bdo><ul id='qXucx'></ul>

      1. 如何将 java.sql.Timestamp 增加 14 天?

        时间:2023-07-27
          <tbody id='ZgxPb'></tbody>

            • <bdo id='ZgxPb'></bdo><ul id='ZgxPb'></ul>

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

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

                2. 本文介绍了如何将 java.sql.Timestamp 增加 14 天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个应用程序,它以时间戳作为 sql 选择的开始日期和结束日期的边界,我想填充一个哈希图,其中自今年的第一个星期一以来的周数作为值和周数作为钥匙.我发现使用时间戳真的很难,而且我对添加 86,400,000 秒来增加一天感觉不太好,因为这不考虑闰日、小时、秒.

                  I have an app that takes a Timestamp as a boundary for the start date and end date of a sql selection, I want to populate a hashmap with weeks this year since the first monday of the year as the values and the week number as the keys. I'm finding it really hard to work with timestamps and I don't feel very good about adding 86,400,000 seconds to it to increment the day, as this doesn't account for the leap days, hours, seconds.

                  我打算在上面加上 13 天 23 小时 59 分 59 秒,这样我就可以在地图中以星期为关键字查找开始日期,然后使用开始日期来获取结束日期.

                  I plan on adding 13 days 23 hours, 59 minutes and 59 seconds to it so that I can lookup the start date in the map by the week as the key, then use the start date to get the end date.

                  所以我想尝试得到这样的东西:

                  So I'm looking to try to get something like this:

                  Week  startDate              endDate
                  1     2011-01-03 00:00:00    2011-01-16 23:59:59
                  2     2011-01-17 00:00:00    2011-01-30 23:59:59
                  

                  地图中的前两列和最后一列是在查找后计算的.如何安全地增加 java.sql.Timestamp?

                  With the first two columns in the Map and the last one being calculated after looking it up. How do I safely increment a java.sql.Timestamp?

                  推荐答案

                  值得注意的是,14 天并不总是 14 * 24 * 3600 秒.当您有夏令时,这可能会更短或更长.从历史上看,它可能比这复杂得多.

                  It worth noting that 14 days is not always 14 * 24 * 3600 seconds. When you have daylight savings, this can be an hour shorter or longer. Historically it can be much more complex than that.

                  相反,我建议使用 JodaTime 或 Calendar 来执行与时区相关的计算.

                  Instead I would suggest using JodaTime or the Calendar to perform the time zone dependant calculation.

                  这篇关于如何将 java.sql.Timestamp 增加 14 天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Java 中输出 RFC 3339 时间戳 下一篇:在Java中将本地时间戳转换为UTC时间戳

                  相关文章

                  最新文章

                  <tfoot id='jh3uQ'></tfoot>
                  <i id='jh3uQ'><tr id='jh3uQ'><dt id='jh3uQ'><q id='jh3uQ'><span id='jh3uQ'><b id='jh3uQ'><form id='jh3uQ'><ins id='jh3uQ'></ins><ul id='jh3uQ'></ul><sub id='jh3uQ'></sub></form><legend id='jh3uQ'></legend><bdo id='jh3uQ'><pre id='jh3uQ'><center id='jh3uQ'></center></pre></bdo></b><th id='jh3uQ'></th></span></q></dt></tr></i><div id='jh3uQ'><tfoot id='jh3uQ'></tfoot><dl id='jh3uQ'><fieldset id='jh3uQ'></fieldset></dl></div>
                3. <legend id='jh3uQ'><style id='jh3uQ'><dir id='jh3uQ'><q id='jh3uQ'></q></dir></style></legend>
                  • <bdo id='jh3uQ'></bdo><ul id='jh3uQ'></ul>
                  1. <small id='jh3uQ'></small><noframes id='jh3uQ'>