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

  • <small id='DiVVx'></small><noframes id='DiVVx'>

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

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

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

        Java 格式小時和分鐘

        Java format hour and min(Java 格式小時和分鐘)

          <small id='5Nq01'></small><noframes id='5Nq01'>

              <bdo id='5Nq01'></bdo><ul id='5Nq01'></ul>

                <tbody id='5Nq01'></tbody>
                  <legend id='5Nq01'><style id='5Nq01'><dir id='5Nq01'><q id='5Nq01'></q></dir></style></legend>

                  <i id='5Nq01'><tr id='5Nq01'><dt id='5Nq01'><q id='5Nq01'><span id='5Nq01'><b id='5Nq01'><form id='5Nq01'><ins id='5Nq01'></ins><ul id='5Nq01'></ul><sub id='5Nq01'></sub></form><legend id='5Nq01'></legend><bdo id='5Nq01'><pre id='5Nq01'><center id='5Nq01'></center></pre></bdo></b><th id='5Nq01'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5Nq01'><tfoot id='5Nq01'></tfoot><dl id='5Nq01'><fieldset id='5Nq01'></fieldset></dl></div>
                1. <tfoot id='5Nq01'></tfoot>
                  本文介紹了Java 格式小時和分鐘的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我需要像這樣格式化我的時間字符串:

                  I need to format my time string such as this:

                  int time = 160;
                  

                  這是我的示例代碼:

                  public static String formatDuration(String minute) {
                      String formattedMinute = null;
                      SimpleDateFormat sdf = new SimpleDateFormat("mm");
                      try {
                          Date dt = sdf.parse(minute);
                          sdf = new SimpleDateFormat("HH mm");
                          formattedMinute = sdf.format(dt);
                      } catch (ParseException e) {
                          e.printStackTrace();
                      }
                      return formattedMinute;
                  //        int minutes = 120;
                  //        int h = minutes / 60 + Integer.parseInt(minute);
                  //        int m = minutes % 60 + Integer.parseInt(minute);
                  //        return h + "hr " + m + "mins";
                  }
                  

                  我需要將其顯示為 2 小時 40 分鐘.但我不知道如何附加小時"和分鐘".要求是不要使用任何庫.

                  I need to display it as 2hrs 40mins. But I don't have a clue how to append the "hrs" and "mins". The requirement is not to use any library.

                  如果您過去做過類似的事情,請隨時提供幫助.非常感謝!

                  If you've done something like this in the past, feel free to help out. Thanks a bunch!

                  推薦答案

                  既然是 2018 年,你真的應(yīng)該使用 Java 8 中引入的日期/時間庫

                  Since, it's 2018, you really should be making use of the Date/Time libraries introduced in Java 8

                  String minutes = "160";
                  Duration duration = Duration.ofMinutes(Long.parseLong(minutes));
                  
                  long hours = duration.toHours();
                  long mins = duration.minusHours(hours).toMinutes();
                  
                  // Or if you're lucky enough to be using Java 9+
                  //String formatted = String.format("%dhrs %02dmins", duration.toHours(), duration.toMinutesPart());
                  String formatted = String.format("%dhrs %02dmins", hours, mins);
                  System.out.println(formatted);
                  

                  哪些輸出...

                  2hrs 40mins
                  

                  為什么要使用這樣的東西?除了通常是更好的 API,當(dāng) minutes 等于 1600 時會發(fā)生什么?

                  Why use something like this? Apart of generally been a better API, what happens when minutes equals something like 1600?

                  上面將顯示 26hrs 40mins,而不是打印 2hrs 40mins.SimpleDateFormat 格式化日期/時間值,它不處理持續(xù)時間

                  Instead of printing 2hrs 40mins, the above will display 26hrs 40mins. SimpleDateFormat formats date/time values, it doesn't deal with duration

                  這篇關(guān)于Java 格式小時和分鐘的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲為 int?)

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

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

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

                          • 主站蜘蛛池模板: 四季久久免费一区二区三区四区 | 爱爱爱av | 91精品国产综合久久福利软件 | 国产91久久精品一区二区 | 春色av| 91精品中文字幕一区二区三区 | www.精品一区 | 四虎影视一区二区 | 手机av网| 精品综合 | 九九九久久国产免费 | 欧美涩涩网 | 日本中文在线视频 | 久久99精品久久久97夜夜嗨 | 久久久网 | 狠狠艹| 欧美日韩中文字幕在线 | 亚洲电影免费 | 国产丝袜av | 国产一区二区欧美 | 欧美久久一级 | 亚洲天堂一区二区 | 超碰在线观看97 | 国产精品欧美一区喷水 | 午夜精品一区二区三区在线播放 | 日韩电影在线一区 | 免费在线国产视频 | 中文字幕精品视频 | 欧美三级电影在线播放 | 在线观看黄色 | 精品毛片在线观看 | 欧美日在线 | 超碰97免费观看 | 91在线观| 国产精品久久久久aaaa | 色婷婷综合成人av | 久久久久国产精品一区三寸 | 日韩视频一区 | 一区二区三区高清在线观看 | 一区二区三区小视频 | 亚洲国产精品美女 |