[英]Java TimeZone update
My system time zone is (UTC+02:00) Istanbul. 我的系统时区是(UTC + 02:00)伊斯坦布尔。 When I run a simple java program to display time zone, it displays "America/Rio_Branco" (which is incorrect).
当我运行一个简单的Java程序以显示时区时,它会显示“ America / Rio_Branco”(不正确)。 But when I set to any other time zones it works correctly.
但是,当我设置为任何其他时区时,它可以正常工作。 Also I updated my jre using tzupdater.jar (I set my path to ..\\jre\\lib).
另外,我使用tzupdater.jar更新了我的jre(我将路径设置为.. \\ jre \\ lib)。 What could be the reason?
可能是什么原因?
My code is : 我的代码是:
import java.util.*;
import java.text.*;
public class Time
{
public static void main(String[] args){
TimeZone timeZone = TimeZone.getDefault();
System.out.println("timeZone : "+timeZone);
}
}
我用来自jre8的文件替换了tzmappings文件,它解决了我的问题。
If you read the JavaDoc you'll see this: 如果您阅读JavaDoc,将会看到以下内容:
Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation.
Thus reason you're getting "America/Rio_Branco" is because the JDK implementation for your host (operating system) thinks you are in Rio Branco's timezone. 因此,得到“ America / Rio_Branco”的原因是因为主机(操作系统)的JDK实现认为您处于Rio Branco的时区。 In the comments you mention you're running Windows 7, so it might be the case that Windows incorrectly has a timezone set somewhere.
在您提到的注释中,您正在运行Windows 7,因此Windows可能会错误地在某个地方设置了时区。 I think Java on Windows checks in the registry here:
我认为Windows上的Java在这里检查注册表:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/TimeZoneInformation
Maybe you can check that value? 也许您可以检查该值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.