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

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

    2. <legend id='2X8S5'><style id='2X8S5'><dir id='2X8S5'><q id='2X8S5'></q></dir></style></legend><tfoot id='2X8S5'></tfoot>

        Java:不可解析的日期異常

        Java: unparseable date exception(Java:不可解析的日期異常)

        <legend id='0KabD'><style id='0KabD'><dir id='0KabD'><q id='0KabD'></q></dir></style></legend>
          1. <small id='0KabD'></small><noframes id='0KabD'>

              <tbody id='0KabD'></tbody>

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

                <bdo id='0KabD'></bdo><ul id='0KabD'></ul>

                  本文介紹了Java:不可解析的日期異常的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  在嘗試轉(zhuǎn)換日期格式時(shí)出現(xiàn)異常:無(wú)法解析的日期并且不知道如何解決此問(wèn)題.

                  While trying to transform the date format I get an exception:unparseable date and don't know how to fix this problem.

                  我收到一個(gè)代表事件日期的字符串,并希望在 GUI 中以不同的格式顯示該日期.

                  I am receiving a string which represents an event date and would like to display this date in different format in GUI.

                  我想要做的是:

                  private String modifyDateLayout(String inputDate){
                          try {
                              //inputDate = "2010-01-04 01:32:27 UTC";
                              Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").parse(inputDate);
                              return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
                          } catch (ParseException e) {
                              e.printStackTrace();
                              return "15.01.2010";
                          }
                      }
                  

                  不管怎樣

                  String modifiedDateString = originalDate.toString();
                  

                  是假的.我想獲取以下格式的日期字符串:

                  is dummy. I would like to get a date string in the following format:

                  dd.MM.yyyy HH:mm:ss

                  dd.MM.yyyy HH:mm:ss

                  輸入字符串示例如下:

                  2010-01-04 01:32:27 UTC

                  2010-01-04 01:32:27 UTC

                  有誰(shuí)知道如何將上面的示例日期(字符串)轉(zhuǎn)換為字符串格式dd.MM.yyyy HH:mm:ss?

                  Does anyone know how to convert the example date (String) above into a String format dd.MM.yyyy HH:mm:ss?

                  謝謝!

                  我修復(fù)了錯(cuò)誤的輸入日期格式,但仍然無(wú)法正常工作.上面是粘貼的方法,下面是調(diào)試會(huì)話的屏幕圖像.

                  I fixed the wrong input date format but still it doesn't work. Above is the pasted method and below is the screen image from debugging session.

                  替代文字 http://img683.imageshack.us/img683/193/dateproblem.png

                  #更新我跑了

                  String[] timezones = TimeZone.getAvailableIDs();
                  

                  并且數(shù)組中有UTC字符串.這是一個(gè)奇怪的問(wèn)題.

                  and there is UTC String in the array. It's a strange problem.

                  我做了一個(gè)有效的骯臟黑客:

                  I did a dirty hack that works:

                  private String modifyDateLayout(String inputDate){
                      try {
                          inputDate = inputDate.replace(" UTC", "");
                          Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(inputDate);
                          return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
                      } catch (ParseException e) {
                          e.printStackTrace();
                          return "15.01.2010";
                      }
                  }
                  

                  但我仍然希望在不削減時(shí)區(qū)的情況下轉(zhuǎn)換原始輸入.

                  But still I would prefer to transform the original input without cutting timezone away.

                  此代碼是為使用 JDK 1.6 的 Android 手機(jī)編寫(xiě)的.

                  This code is written for Android phone using JDK 1.6.

                  推薦答案

                  你在這里基本上做的是依賴 Date#toString() 已經(jīng)有一個(gè)固定的模式.要將 Java Date 對(duì)象轉(zhuǎn)換為另一種人類可讀的字符串模式,您需要 SimpleDateFormat#format().

                  What you're basically doing here is relying on Date#toString() which already has a fixed pattern. To convert a Java Date object into another human readable String pattern, you need SimpleDateFormat#format().

                  private String modifyDateLayout(String inputDate) throws ParseException{
                      Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").parse(inputDate);
                      return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
                  }
                  

                  順便說(shuō)一下,這里只能SimpleDateFormat#parse().這意味著 inputDate 不在預(yù)期的模式 "yyyy-MM-dd HH:mm:ss z" 中.您可能需要修改模式以匹配 inputDate 的實(shí)際模式.

                  By the way, the "unparseable date" exception can here only be thrown by SimpleDateFormat#parse(). This means that the inputDate isn't in the expected pattern "yyyy-MM-dd HH:mm:ss z". You'll probably need to modify the pattern to match the inputDate's actual pattern.

                  更新:好的,我做了一個(gè)測(cè)試:

                  Update: Okay, I did a test:

                  public static void main(String[] args) throws Exception {
                      String inputDate = "2010-01-04 01:32:27 UTC";
                      String newDate = new Test().modifyDateLayout(inputDate);
                      System.out.println(newDate);
                  }
                  

                  這正確打印:

                  03.01.2010 21:32:27
                  

                  (我在 GMT-4)

                  更新 2: 根據(jù)您的編輯,您確實(shí)得到了一個(gè) ParseException.最可疑的部分將是 UTC 的時(shí)區(qū).這在您的 Java 環(huán)境中實(shí)際上是已知嗎?您使用的是什么 Java 版本和什么操作系統(tǒng)版本?檢查 TimeZone.getAvailableIDs().中間必須有一個(gè)UTC.

                  Update 2: as per your edit, you really got a ParseException on that. The most suspicious part would then be the timezone of UTC. Is this actually known at your Java environment? What Java version and what OS version are you using? Check TimeZone.getAvailableIDs(). There must be a UTC in between.

                  這篇關(guān)于Java:不可解析的日期異常的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語(yǔ)句之前的局部變量,這有關(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)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)
                    <tbody id='BFEqM'></tbody>

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

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

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

                            主站蜘蛛池模板: 特级毛片www | 亚洲区一区二区 | 欧美一级欧美三级在线观看 | 国产区精品在线观看 | 欧美日韩国产综合在线 | 超碰97在线免费 | 三区在线 | 久久久久久亚洲 | 久久精品免费看 | 在线看免费 | 久久精品国产99国产 | 黄色免费在线网址 | 欧美日韩亚洲一区 | 日韩成人免费视频 | 午夜爽爽爽男女免费观看 | 91久久久久久久久久久久久 | 精品一区二区三区在线观看 | 欧美一级片免费看 | 青青久久 | 成人在线观看欧美 | 日韩中文字幕一区 | 国产美女精品视频 | 国产精品免费在线 | 亚洲成人av在线播放 | 日韩精品影院 | 日韩插插 | 99精品一区二区三区 | 国产精品二区三区在线观看 | 一区二区三区四区不卡 | 日韩国产专区 | 国产一区二区在线视频 | 亚洲精品一区二区三区中文字幕 | 精品三区| 国产欧美日韩一区二区三区 | 欧美性网 | 国产成视频在线观看 | 日本三级电影免费观看 | 我想看一级黄色毛片 | 久久久亚洲一区 | 国产精品亚洲成在人线 | 亚洲另类自拍 |