<legend id='vnw0G'><style id='vnw0G'><dir id='vnw0G'><q id='vnw0G'></q></dir></style></legend>
        <tfoot id='vnw0G'></tfoot>

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

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

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

        LocalDateTime 的长时间戳

        时间:2023-07-25
      1. <tfoot id='NgeCP'></tfoot>

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

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

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

                  本文介绍了LocalDateTime 的长时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个长时间戳 1499070300(相当于 2017 年 7 月 3 日星期一 16:25:00 +0800),但是当我将其转换为 LocalDateTime 时,我得到 1970-01-18T16:24:30.300

                  I have a long timestamp 1499070300 (equivalent to Mon, 03 Jul 2017 16:25:00 +0800) but when I convert it to LocalDateTime I get 1970-01-18T16:24:30.300

                  这是我的代码

                  long test_timestamp = 1499070300;
                  
                  LocalDateTime triggerTime =
                                  LocalDateTime.ofInstant(Instant.ofEpochMilli(test_timestamp), TimeZone
                                          .getDefault().toZoneId());
                  

                  推荐答案

                  需要以毫秒为单位传递时间戳:

                  You need to pass timestamp in milliseconds:

                  long test_timestamp = 1499070300000L;
                  LocalDateTime triggerTime =
                          LocalDateTime.ofInstant(Instant.ofEpochMilli(test_timestamp), 
                                                  TimeZone.getDefault().toZoneId());  
                  
                  System.out.println(triggerTime);
                  

                  结果:

                  2017-07-03T10:25
                  

                  或者使用 ofEpochSecond 代替:

                  long test_timestamp = 1499070300L;
                  LocalDateTime triggerTime =
                         LocalDateTime.ofInstant(Instant.ofEpochSecond(test_timestamp),
                                                 TimeZone.getDefault().toZoneId());   
                  
                  System.out.println(triggerTime);
                  

                  结果:

                  2017-07-03T10:25
                  

                  这篇关于LocalDateTime 的长时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何创建漩涡/漩涡效果? 下一篇:来自 ZonedDateTime UTC 实例的 Java 日期和时间戳

                  相关文章

                  最新文章

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

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

                    <legend id='AzzRU'><style id='AzzRU'><dir id='AzzRU'><q id='AzzRU'></q></dir></style></legend>
                    <tfoot id='AzzRU'></tfoot>

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