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

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

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

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

        <legend id='UDu01'><style id='UDu01'><dir id='UDu01'><q id='UDu01'></q></dir></style></legend>

        Java 时区 - IST 的奇怪行为?

        Java timezone - strange behavior with IST?(Java 时区 - IST 的奇怪行为?)
          • <bdo id='cA8PM'></bdo><ul id='cA8PM'></ul>
            <legend id='cA8PM'><style id='cA8PM'><dir id='cA8PM'><q id='cA8PM'></q></dir></style></legend>

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

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

                1. <tfoot id='cA8PM'></tfoot>
                    <tbody id='cA8PM'></tbody>
                  本文介绍了Java 时区 - IST 的奇怪行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下代码:

                  DateFormat df = new SimpleDateFormat("M/d/yy h:mm a z");
                  df.setLenient(false);
                  System.out.println(df.parse("6/29/2012 5:15 PM IST"));
                  

                  假设我现在将 PC 的时区设置为太平洋时间(PDT 为 UTC-7),这将打印出来

                  Assuming I now set my PC's timezone to Pacific Time (UTC-7 for PDT), this prints

                  2012 年 6 月 29 日星期五 08:15:00 PDT

                  Fri Jun 29 08:15:00 PDT 2012

                  PDT 不是比 IST(印度标准时间)晚 12.5 小时吗?任何其他时区都不会出现此问题 - 我在日期字符串中尝试了 UTC、PKT、MMT 等而不是 IST.Java中是否有两个IST?

                  Isn't PDT 12.5 hours behind IST (Indian Standard Time)? This problem does not occur for any other timezone - I tried UTC, PKT, MMT etc instead of IST in the date string. Are there two ISTs in Java by any chance?

                  P.S:实际代码中的日期字符串来自外部来源,所以我不能使用 GMT 偏移量或任何其他时区格式.

                  P.S: The date string in the actual code comes from an external source, so I cannot use GMT offset or any other timezone format.

                  推荐答案

                  对不起,我必须为此写一个答案,但试试这个代码:

                  Sorry, I have to write an answer for this, but try this code:

                  public class Test {
                  
                      public static void main(String[] args) throws ParseException {
                          DF df = new DF("M/d/yy h:mm a z");
                          String [][] zs = df.getDateFormatSymbols().getZoneStrings();
                          for( String [] z : zs ) {
                              System.out.println( Arrays.toString( z ) );
                          }
                      }
                  
                      private static class DF extends SimpleDateFormat {
                          @Override
                          public DateFormatSymbols getDateFormatSymbols() {
                              return super.getDateFormatSymbols();
                          }
                  
                          public DF(String pattern) {
                              super(pattern);
                          }
                      }
                  
                  }
                  

                  您会发现 IST 在列表中出现了好几次,第一个确实是以色列标准时间.

                  You'll find that IST appears several times in the list and the first one is indeed Israel Standard Time.

                  这篇关于Java 时区 - IST 的奇怪行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                      <tbody id='zAPQy'></tbody>
                    1. <tfoot id='zAPQy'></tfoot><legend id='zAPQy'><style id='zAPQy'><dir id='zAPQy'><q id='zAPQy'></q></dir></style></legend>

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

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