久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <tfoot id='pHunq'></tfoot>

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

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

    2. Java:當秒和毫秒都為 0 時,DateTimeFormatter 無法解析

      Java: DateTimeFormatter fail to parse time string when seconds and milliseconds are all 0s?(Java:當秒和毫秒都為 0 時,DateTimeFormatter 無法解析時間字符串?)
      <legend id='yD0ff'><style id='yD0ff'><dir id='yD0ff'><q id='yD0ff'></q></dir></style></legend>
      • <bdo id='yD0ff'></bdo><ul id='yD0ff'></ul>
        <tfoot id='yD0ff'></tfoot>
          1. <i id='yD0ff'><tr id='yD0ff'><dt id='yD0ff'><q id='yD0ff'><span id='yD0ff'><b id='yD0ff'><form id='yD0ff'><ins id='yD0ff'></ins><ul id='yD0ff'></ul><sub id='yD0ff'></sub></form><legend id='yD0ff'></legend><bdo id='yD0ff'><pre id='yD0ff'><center id='yD0ff'></center></pre></bdo></b><th id='yD0ff'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yD0ff'><tfoot id='yD0ff'></tfoot><dl id='yD0ff'><fieldset id='yD0ff'></fieldset></dl></div>

                <tbody id='yD0ff'></tbody>
            1. <small id='yD0ff'></small><noframes id='yD0ff'>

                本文介紹了Java:當秒和毫秒都為 0 時,DateTimeFormatter 無法解析時間字符串?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                基本上,我使用以下代碼將字符串解析為 LocalDateTime,這在大多數(shù)情況下都可以正常工作.

                DateTimeFormatter dtformatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");

                但是,我遇到秒和毫秒為 00000 的情況,這是解析器失敗并打印 LocalDateTime 2018-03-01T09:16 而不是 2018-03-01T09:16:00.000.

                System.out.println(LocalDateTime.parse("20180301091600000",dtformatter));

                (請注意,在我的代碼中,我必須將字符串解析為 LocalDateTime,進行一些比較,然后最后將 LocalDateTime 打印到 csv)

                如何修復它以使其打印 2018-03-01T09:16:00.000 而不是 2018-03-01T09:16 ?

                僅供參考,我正在使用 jdk10.

                解決方案

                我不知道為什么它不起作用,它似乎是一個 bug 因為當我使用:

                20180301091600001 結果是 2018-03-01T09:16:00.001----------------^ -----------------^^^^^^

                還有另一個測試:

                2018030100000000 結果是 2018-03-01T00:00--------^^^------------------^^^^^^^^^^^

                解析器好像忽略了毫秒為零的時候,為什么?

                為什么?的完整解釋在 Basil Bourque 的回答中.p>


                解決方案

                這是一個快速修復,您可以使用其他格式化程序,如下所示:

                var 結果 = LocalDateTime.parse("20180301091600000", dtformatter).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss:SSS"));

                輸出

                2018-03-01T09:16:00:000

                Basically, I am using the following code to parse string as LocalDateTime, which works fine most of the time.

                DateTimeFormatter dtformatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
                

                However, I encounter cases where the seconds and millseconds are 00000 and this is when the parser fails and print a LocalDateTime 2018-03-01T09:16 instead of 2018-03-01T09:16:00.000.

                System.out.println(LocalDateTime.parse("20180301091600000",dtformatter));
                

                (Note that in my code, I have to parse string as LocalDateTime, do some comparison and then at the end, print LocalDateTime to csv)

                How can I fix it to make it print 2018-03-01T09:16:00.000 instead of 2018-03-01T09:16 ?

                FYI, I am using jdk10.

                解決方案

                I'm not sure why it's not work, it seems it is a bug because when I use :

                20180301091600001        result is      2018-03-01T09:16:00.001
                ----------------^                       -----------------^^^^^^
                

                Also another test :

                2018030100000000         result is      2018-03-01T00:00
                --------^^^-----                        -----------^^^^^^^^^^^
                

                It seems that the parser ignore the seconds and millisecond when it is zero, why?

                The full explanation why?, is in the answer of Basil Bourque.


                Solution

                Here is a quick fix where you can use another formatter like this :

                var result = LocalDateTime.parse("20180301091600000", dtformatter)
                                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss:SSS"));
                

                Output

                2018-03-01T09:16:00:000
                

                這篇關于Java:當秒和毫秒都為 0 時,DateTimeFormatter 無法解析時間字符串?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                How to convert Integer to int?(如何將整數(shù)轉換為整數(shù)?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                <i id='f7uIx'><tr id='f7uIx'><dt id='f7uIx'><q id='f7uIx'><span id='f7uIx'><b id='f7uIx'><form id='f7uIx'><ins id='f7uIx'></ins><ul id='f7uIx'></ul><sub id='f7uIx'></sub></form><legend id='f7uIx'></legend><bdo id='f7uIx'><pre id='f7uIx'><center id='f7uIx'></center></pre></bdo></b><th id='f7uIx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='f7uIx'><tfoot id='f7uIx'></tfoot><dl id='f7uIx'><fieldset id='f7uIx'></fieldset></dl></div>

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

                      <tbody id='f7uIx'></tbody>
                    <legend id='f7uIx'><style id='f7uIx'><dir id='f7uIx'><q id='f7uIx'></q></dir></style></legend>

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

                        • <tfoot id='f7uIx'></tfoot>
                        • 主站蜘蛛池模板: 黑色丝袜三级在线播放 | 自拍偷拍中文字幕 | 一区二区三区av | 欧产日产国产精品视频 | 久久久精品综合 | 国产精品一区在线观看 | 超碰520| 三区四区在线观看 | 免费视频一区二区 | 国产精品久久亚洲7777 | 欧美在线a | 精品成人av | 国产一区二区黑人欧美xxxx | www,黄色,com | 国产精品久久久久久久久 | 精品一区二区三区在线播放 | 黄色在线免费播放 | 国内毛片毛片毛片毛片 | 羞羞免费网站 | 亚洲成人av | 久久久91精品国产一区二区三区 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 国产极品粉嫩美女呻吟在线看人 | 岛国av一区二区 | 精品亚洲一区二区 | 激情欧美日韩一区二区 | 中文字幕免费 | 精品视频一区二区 | 久久偷人 | 日韩三级电影在线看 | 成人在线观 | 一区二区精品 | 久久狠狠| 91精品国产91久久综合桃花 | 在线观看a视频 | 在线视频 中文字幕 | 国产日韩一区 | av网站免费看| 国产精品免费一区二区三区四区 | 色狠狠桃花综合 | 亚洲高清在线免费观看 |