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

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

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

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

        如何为秒值打印高达 6 位精度的时间

        时间:2023-07-26
          <bdo id='ionlZ'></bdo><ul id='ionlZ'></ul>
          <legend id='ionlZ'><style id='ionlZ'><dir id='ionlZ'><q id='ionlZ'></q></dir></style></legend>

                <tfoot id='ionlZ'></tfoot>

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

                • <i id='ionlZ'><tr id='ionlZ'><dt id='ionlZ'><q id='ionlZ'><span id='ionlZ'><b id='ionlZ'><form id='ionlZ'><ins id='ionlZ'></ins><ul id='ionlZ'></ul><sub id='ionlZ'></sub></form><legend id='ionlZ'></legend><bdo id='ionlZ'><pre id='ionlZ'><center id='ionlZ'></center></pre></bdo></b><th id='ionlZ'></th></span></q></dt></tr></i><div id='ionlZ'><tfoot id='ionlZ'></tfoot><dl id='ionlZ'><fieldset id='ionlZ'></fieldset></dl></div>
                    <tbody id='ionlZ'></tbody>
                • 本文介绍了如何为秒值打印高达 6 位精度的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在列中有一个时间戳类型的值.假设我有一个值 2007-05-04 08:48:40.969774

                  I have a value in column which is of type timestamp. Lets say I have a value 2007-05-04 08:48:40.969774

                  现在,当尝试从数据库中获取值并将此时间戳值返回给函数时,我应该使用什么 SimpleDateFormatter 模式,以便也返回秒旁边的小数部分.

                  Now, when trying to fetch the value from the database and return this timestamp value to a function, what SimpleDateFormatter pattern should I use so that the fraction part beside the seconds also gets returned.

                  我使用了 yyyy-MM-dd hh:mm:ss,但它只返回到秒数,并忽略秒数旁边的分数 (.969774).我还需要帮助以 6 位精度返回这个小数部分.

                  I have used yyyy-MM-dd hh:mm:ss, but that only returns till the seconds and ignores the fraction present beside the seconds(.969774). I need help in returning this fraction part also, with a 6-digits precision.

                  推荐答案

                  java.util.Date(或java.sql.Timestamp)的默认格式化方式只有毫秒精度.您可以使用 yyyy-MM-dd hh:mm:ss.SSS 来获得毫秒精度.

                  The default ways of formatting a java.util.Date (or java.sql.Timestamp) has only millisecond precision. You can use yyyy-MM-dd hh:mm:ss.SSS to get that millisecond precision.

                  java.sql.Timestamp 实际上确实具有(高达)纳秒精度(假设数据库服务器和驱动程序实际上支持它).在 Java 8 中格式化它的最简单方法是将时间戳转换为 java.time.LocalDateTime(使用 Timestamp.toLocalDateTime())并使用 javajava.time.format.DateTimeFormatter 中的 .time 格式选项,最多支持纳秒.

                  A java.sql.Timestamp actually does have (up to) nanosecond precision (assuming the database server and the driver actually support it). The easiest way to format it in Java 8 is to convert the timestamp to a java.time.LocalDateTime (using Timestamp.toLocalDateTime()) and use the java.time formatting options in java.time.format.DateTimeFormatter which support up to nanoseconds.

                  如果您使用 Java 7 或更早版本,则需要付出一些额外的努力,因为普通的日期格式化程序不支持它.例如,您可以使用带有模式 yyyy-MM-dd hh:mm:ss 的日期格式化程序(仅格式化为秒)并附加亚秒纳秒(带有适当的零填充)Timestamp.getNanos() 你自己.

                  If you use Java 7 or earlier it will take some extra effort, as the normal date formatters don't support it. For example you could use a dateformatter with pattern yyyy-MM-dd hh:mm:ss (to only format up to seconds) and append the sub-second nano seconds (with appropriate zero-padding) of Timestamp.getNanos() yourself.

                  这篇关于如何为秒值打印高达 6 位精度的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 XMLGregorianCalendar 转换为 java.sql.Timestamp 下一篇:如何将 java.sql.Timestamp(yyyy-MM-dd HH:mm:ss.S) 格式化为

                  相关文章

                  最新文章

                • <tfoot id='u7I5V'></tfoot>

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

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

                  1. <legend id='u7I5V'><style id='u7I5V'><dir id='u7I5V'><q id='u7I5V'></q></dir></style></legend>
                      <bdo id='u7I5V'></bdo><ul id='u7I5V'></ul>