2007-09-28

时区转换代码

java 代码
  1. timeZone_digital = new Date().getTimezoneOffset() 得到时区时间差值      
  2.      
  3. 以上是JS得到的       
  4.     public static TimeZone getTimeZone(String timeZone_digital) {      
  5.         String gmt = "";      
  6.         if (timeZone_digital != null) {      
  7.             int length = timeZone_digital.length();      
  8.             String d = "";      
  9.             String f = "";      
  10.             if (length == 1) {      
  11.                 gmt = "GMT";      
  12.             } else if (timeZone_digital.startsWith("-")) {      
  13.                 d = timeZone_digital.substring(01);      
  14.                 f = timeZone_digital.substring(1, length);      
  15.                 gmt = "GMT+" + Integer.parseInt(f) / 60;      
  16.             } else {      
  17.                 gmt = "GMT-" + Integer.parseInt(timeZone_digital) / 60;      
  18.             }      
  19.      
  20.         } else {      
  21.             // 北京时区      
  22.             return TimeZone.getTimeZone("GMT+8");      
  23.         }      
  24.      
  25.         return TimeZone.getTimeZone(gmt);      
  26.     }      
  27.      
评论
发表评论

您还没有登录,请登录后发表评论

cnhzliye
搜索本博客
存档
最新评论