• <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中的日期时区转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='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>