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

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

      1. <legend id='UeUwM'><style id='UeUwM'><dir id='UeUwM'><q id='UeUwM'></q></dir></style></legend><tfoot id='UeUwM'></tfoot>
      2. 将 LocalDate 转换为 LocalDateTime 或 java.sql.Timestamp

        时间:2023-07-27
        1. <i id='dODa8'><tr id='dODa8'><dt id='dODa8'><q id='dODa8'><span id='dODa8'><b id='dODa8'><form id='dODa8'><ins id='dODa8'></ins><ul id='dODa8'></ul><sub id='dODa8'></sub></form><legend id='dODa8'></legend><bdo id='dODa8'><pre id='dODa8'><center id='dODa8'></center></pre></bdo></b><th id='dODa8'></th></span></q></dt></tr></i><div id='dODa8'><tfoot id='dODa8'></tfoot><dl id='dODa8'><fieldset id='dODa8'></fieldset></dl></div>
            <tbody id='dODa8'></tbody>

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

            <tfoot id='dODa8'></tfoot>
              <bdo id='dODa8'></bdo><ul id='dODa8'></ul>
            • <legend id='dODa8'><style id='dODa8'><dir id='dODa8'><q id='dODa8'></q></dir></style></legend>

                • 本文介绍了将 LocalDate 转换为 LocalDateTime 或 java.sql.Timestamp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 JodaTime 1.6.2.

                  I am using JodaTime 1.6.2.

                  我有一个 LocalDate,我需要将其转换为 (Joda) LocalDateTimejava.sqlTimestamp 以进行映射.

                  I have a LocalDate that I need to convert to either a (Joda) LocalDateTime, or a java.sqlTimestamp for ormapping.

                  原因是我已经弄清楚如何在 LocalDateTimejava.sql.Timestamp 之间进行转换:

                  The reason for this is I have figured out how to convert between a LocalDateTime and a java.sql.Timestamp:

                  LocalDateTime ldt = new LocalDateTime();
                  DateTimeFormatter dtf = DateTimeFormatter.forPattern("yyyy-MM-dd HH:mm:ss");
                  Timestamp ts = Timestamp.valueOf(ldt.toString(dtf));
                  

                  所以,如果我可以在 LocalDateLocalDateTime 之间进行转换,那么我可以继续转换为 java.sql.Timestamp.感谢您在正确方向上的任何推动!

                  So, if I can just convert between LocalDate and LocalDateTime, then I can make the continued conversion to java.sql.Timestamp. Thanks for any nudges in the right direction!

                  推荐答案

                  JodaTime

                  要转换 JodaTime 的 org.joda.time.LocalDatejava.sql.Timestamp,做就行了

                  Timestamp timestamp = new Timestamp(localDate.toDateTimeAtStartOfDay().getMillis());
                  

                  要转换 JodaTime 的 org.joda.time.LocalDateTimejava.sql.Timestamp,做就行了

                  To convert JodaTime's org.joda.time.LocalDateTime to java.sql.Timestamp, just do

                  Timestamp timestamp = new Timestamp(localDateTime.toDateTime().getMillis());
                  


                  Java时间

                  转换Java8的java.time.LocalDatejava.sql.Timestamp,就这么做

                  Timestamp timestamp = Timestamp.valueOf(localDate.atStartOfDay());
                  

                  要转换 Java8 的 java.time.LocalDateTimejava.sql.Timestamp,就这么做

                  To convert Java8's java.time.LocalDateTime to java.sql.Timestamp, just do

                  Timestamp timestamp = Timestamp.valueOf(localDateTime);
                  

                  这篇关于将 LocalDate 转换为 LocalDateTime 或 java.sql.Timestamp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android获取当前时间戳? 下一篇:Java 时间戳 - 如何创建日期为 23/09/2007 的时间戳

                  相关文章

                  最新文章

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

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