Solution to the Java acquisition time error after updating XP

Source: Internet
Author: User

Yesterday XP automatic Update, prompt, I inadvertently saw an update is about the time zone update, then did not control what, because WinXP Automatic Updates will not bring any harm to the computer, who knows, after a period of time, just my program to get the computer, It was eight hours less than when I showed it on my computer.

So the internet to check, to see who has touched this problem, a check still really someone has encountered this problem, but the solution is no more than every time in the acquisition times, the default time zone to East Eight area, there are several methods:

1, add the following in the System attribute:

System.setproperty ("User.timezone", "Asia/shanghai");

2, change the default time zone to our time zone:

TimeZone TZ = Timezone.gettimezone ("Asia/shanghai");

Timezone.setdefault (TZ);

But all of these methods can only be used in our own applications, when we get time, change the time zone, but for those application servers, they later log something, the time is certainly wrong. So I think there is a third way to restore the computer to the update before, so do not add any code, Java gets the time is correct, just like update before, but my computer turned off the System Restore, and then found some uninstall tools, uninstall the updated update package, but the time zone of the update package is not unloaded.

Later think is not updated after the registry what is different? Open and look,

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones]

Sure enough, and my colleagues did not update the registry on the computer is not the same, it's that node led out is 128KB, my only 72KB, so I import his try, and then open NetBeans, and then print out the time, and finally the system with the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.