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

        • <bdo id='G5oc7'></bdo><ul id='G5oc7'></ul>
        <i id='G5oc7'><tr id='G5oc7'><dt id='G5oc7'><q id='G5oc7'><span id='G5oc7'><b id='G5oc7'><form id='G5oc7'><ins id='G5oc7'></ins><ul id='G5oc7'></ul><sub id='G5oc7'></sub></form><legend id='G5oc7'></legend><bdo id='G5oc7'><pre id='G5oc7'><center id='G5oc7'></center></pre></bdo></b><th id='G5oc7'></th></span></q></dt></tr></i><div id='G5oc7'><tfoot id='G5oc7'></tfoot><dl id='G5oc7'><fieldset id='G5oc7'></fieldset></dl></div>
        <legend id='G5oc7'><style id='G5oc7'><dir id='G5oc7'><q id='G5oc7'></q></dir></style></legend>
        <tfoot id='G5oc7'></tfoot>
      1. 解析 DateFormat 时的 Java 时区

        Java Time Zone When Parsing DateFormat(解析 DateFormat 时的 Java 时区)
            <bdo id='UkSMH'></bdo><ul id='UkSMH'></ul>
            1. <tfoot id='UkSMH'></tfoot>
              <i id='UkSMH'><tr id='UkSMH'><dt id='UkSMH'><q id='UkSMH'><span id='UkSMH'><b id='UkSMH'><form id='UkSMH'><ins id='UkSMH'></ins><ul id='UkSMH'></ul><sub id='UkSMH'></sub></form><legend id='UkSMH'></legend><bdo id='UkSMH'><pre id='UkSMH'><center id='UkSMH'></center></pre></bdo></b><th id='UkSMH'></th></span></q></dt></tr></i><div id='UkSMH'><tfoot id='UkSMH'></tfoot><dl id='UkSMH'><fieldset id='UkSMH'></fieldset></dl></div>

                <tbody id='UkSMH'></tbody>

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

                  <legend id='UkSMH'><style id='UkSMH'><dir id='UkSMH'><q id='UkSMH'></q></dir></style></legend>
                • 本文介绍了解析 DateFormat 时的 Java 时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有如下解析日期的代码:

                  I had code that parses date as follows:

                  String ALT_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
                  SimpleDateFormat sdf = new SimpleDateFormat(
                                      ALT_DATE_TIME_FORMAT);
                  Date date = sdf.parse(requiredTimeStamp);
                  

                  它工作正常,突然间,它停止工作了.事实证明,管理员在服务器上进行了一些配置更改,并且日期当前返回为2010-12-27T10:50:44.000-08:00",上述模式无法解析.我有两个问题:

                  And it was working fine, suddenly, this stopped working. It turns out an admin made some config changes on the server and the date is currently being returned as "2010-12-27T10:50:44.000-08:00" which is not parse-able by the above pattern. I have two questions:

                  第一个是什么模式会解析 JVM 以上述格式返回的日期(具体来说,只是 '-08:00' 作为时区)?其次,究竟应该在哪里更改 linux RHEL 5 服务器上的此类设置,以便我们在未来了解此类更改?

                  The first would be what pattern would parse the date being returned by the JVM in the format above (specifically, just '-08:00' as the time zone)? And second, where exactly would one change such settings on a linux RHEL 5 server so that we are aware of such changes in the future?

                  推荐答案

                  另一个应用程序正在使用 ISO 8601 dateTime 格式.我假设另一个应用程序正在向您发送一个符合 XML Schema 的 dateTime 类型(即 ISO 8601)的 XML 响应.现在,众所周知,DateFormat 无法解析这种格式.您要么必须使用其他库,例如 joda-time(joda-time 是赢家),要么必须使用其他响应中指定的 FastDateFormat.看这篇文章Converting ISO 8601-compliant String to java.util.Date

                  The other application is using the ISO 8601 dateTime format. I am assuming the other application is sending you an XML response that is in compliance with XML Schema's dateTime type, which is ISO 8601. Now, it is a known thing that the DateFormat can't parse this format. You either have to use other libraries like joda-time (joda-time is the winner) or the FastDateFormat as specified in the other responses. Look at this post Converting ISO 8601-compliant String to java.util.Date

                  这篇关于解析 DateFormat 时的 Java 时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)

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

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

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