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

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

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

  2. <tfoot id='vT8ty'></tfoot>

      如何将 Timestamp 转换为 Date 或 DateTime 对象?

      时间:2023-07-25
          <tbody id='0Y3jC'></tbody>
        1. <small id='0Y3jC'></small><noframes id='0Y3jC'>

          • <tfoot id='0Y3jC'></tfoot><legend id='0Y3jC'><style id='0Y3jC'><dir id='0Y3jC'><q id='0Y3jC'></q></dir></style></legend>

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

            • <bdo id='0Y3jC'></bdo><ul id='0Y3jC'></ul>
                本文介绍了如何将 Timestamp 转换为 Date 或 DateTime 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在使用 ResultSet.getTimestamp() 从数据库中检索时间戳对象,但我想要一种简单的方法来获取 MM/DD/格式的日期YYYYHH:MM xx 格式的时间.我正在修补,看起来我可以通过使用 Java 中的 Date 和/或 DateTime 对象来做到这一点.这是最好的方法,还是我什至需要转换时间戳来完成这个?任何建议都会有所帮助.

                I'm retrieving a timestamp object from a database using ResultSet.getTimestamp(), but I'd like an easy way to get the date in the format of MM/DD/YYYY and the time in a format of HH:MM xx. I was tinkering around, it it looks as though I can do such by making use of the Date and/or DateTime objects within Java. Is that the best way to go, or do I even need to convert the timestamp to accomplish this? Any recommendations would be helpful.

                ....
                while(resultSet.next()) {
                    Timestamp dtStart = resultSet.getTimestamp("dtStart");
                    Timestamp dtEnd = resultSet.getTimestamp("dtEnd");
                
                    // I would like to then have the date and time
                    // converted into the formats mentioned...
                    ....
                }
                ....
                

                推荐答案

                java.sql.Timestampjava.util.Date.所以,只是向上吧.

                java.sql.Timestamp is a subclass of java.util.Date. So, just upcast it.

                Date dtStart = resultSet.getTimestamp("dtStart");
                Date dtEnd = resultSet.getTimestamp("dtEnd");
                

                使用 SimpleDateFormat 并创建 Joda DateTime 从现在开始应该是直截了当的.

                Using SimpleDateFormat and creating Joda DateTime should be straightforward from this point on.

                这篇关于如何将 Timestamp 转换为 Date 或 DateTime 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何计算两个 Java java.sql.Timestamps 之间的差异? 下一篇:Hibernate 在读取 Java 日历对象并将其写入 SQL TIME

                相关文章

                最新文章

                • <bdo id='zwujv'></bdo><ul id='zwujv'></ul>
                <tfoot id='zwujv'></tfoot>

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

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

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