• <legend id='UnBkS'><style id='UnBkS'><dir id='UnBkS'><q id='UnBkS'></q></dir></style></legend>

      <bdo id='UnBkS'></bdo><ul id='UnBkS'></ul>
  • <small id='UnBkS'></small><noframes id='UnBkS'>

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

      <tfoot id='UnBkS'></tfoot>
      1. java中的日期时区转换?

        Date TimeZone conversion in java?(java中的日期时区转换?)
          <bdo id='0robQ'></bdo><ul id='0robQ'></ul>

              1. <i id='0robQ'><tr id='0robQ'><dt id='0robQ'><q id='0robQ'><span id='0robQ'><b id='0robQ'><form id='0robQ'><ins id='0robQ'></ins><ul id='0robQ'></ul><sub id='0robQ'></sub></form><legend id='0robQ'></legend><bdo id='0robQ'><pre id='0robQ'><center id='0robQ'></center></pre></bdo></b><th id='0robQ'></th></span></q></dt></tr></i><div id='0robQ'><tfoot id='0robQ'></tfoot><dl id='0robQ'><fieldset id='0robQ'></fieldset></dl></div>
                <legend id='0robQ'><style id='0robQ'><dir id='0robQ'><q id='0robQ'></q></dir></style></legend>
                  <tbody id='0robQ'></tbody>
              2. <small id='0robQ'></small><noframes id='0robQ'>

                <tfoot id='0robQ'></tfoot>
                • 本文介绍了java中的日期时区转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在寻找将时间从 GMT 转换为本地时间的最简单方法.当然,要考虑正确的 DST 日期并尽可能标准.

                  I was looking for the simplest way to convert a date an time from GMT to my local time. Of course, having the proper DST dates considered and as standard as possible.

                  我能想到的最直接的代码是:

                  The most straight forward code I could come up with was:

                  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                  String inpt = "2011-23-03 16:40:44";
                  Date inptdate = null;
                  try {
                      inptdate = sdf.parse(inpt);
                  } catch (ParseException e) {e.printStackTrace();}   
                  Calendar tgmt = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
                  tgmt.setTime(inptdate);
                  
                  Calendar tmad = new GregorianCalendar(TimeZone.getTimeZone("Europe/Madrid"));
                  tmad.setTime(inptdate);
                  
                  System.out.println("GMT:		" + sdf.format(tgmt.getTime()));
                  System.out.println("Europe/Madrid:	" + sdf.format(tmad.getTime()));
                  

                  但我认为我没有正确理解 getTime 将返回的内容.

                  But I think I didn't get the right concept for what getTime will return.

                  推荐答案

                  这里的问题是 DateFormat 类有一个时区.试试这个例子:

                  The catch here is that the DateFormat class has a timezone. Try this example instead:

                      SimpleDateFormat sdfgmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                      sdfgmt.setTimeZone(TimeZone.getTimeZone("GMT"));
                  
                      SimpleDateFormat sdfmad = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                      sdfmad.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));
                  
                      String inpt = "2011-23-03 16:40:44";
                      Date inptdate = null;
                      try {
                          inptdate = sdfgmt.parse(inpt);
                      } catch (ParseException e) {e.printStackTrace();}
                  
                      System.out.println("GMT:		" + sdfgmt.format(inptdate));
                      System.out.println("Europe/Madrid:	" + sdfmad.format(inptdate));
                  

                  这篇关于java中的日期时区转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 中的默认语言环境设置以使其保持一致?)

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

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

                          <tbody id='AI9mt'></tbody>
                          <bdo id='AI9mt'></bdo><ul id='AI9mt'></ul>
                          • <tfoot id='AI9mt'></tfoot>