In eclipse/MyEclipse, if you annotate or run System. out. print (new java. util. date (); the time difference between the system and the time is 8 hours.
It can be noted that your time zone does not correspond to the current time zone. The time zone we use in China is Asia/Shanghai. Your difference of 8 hours should be in UTC + 8. About this
If you don't understand, you can look at junior high school geography: D.
There are two solutions:
1. Set the time zone in the jre running parameters of your eclipse/MyEclipse JVM. In the Default VM Arguments, set-Duser. timezone = Asia/Shanghai.
Step: In Window-> Preferences-> Java-> Installed JERs, view the jre installation list on the right, select one, and click edit,
Then, set-Duser. timezone = Asia/Shanghai in the Default VM Arguments.
Click Finish to restart eclipse and MyEclipse;
2. The reason for this time zone difference is that the time zone settings of the Software Registry of the system are damaged. Just register it again.
Someone on Javaeye also provides the Registry download: Time_Zones_XP.rar
Run the registry after decompression.
In eclipse/MyEclipse, if you find that your comments are in the English format (Mon Mar 21 10:57:13 CST 2011), instead of the Chinese format or the format you want, you can solve the problem as follows.
1. In eclipse. ini, myeclipse. add-Duser to the configuration file of in. language = zh-cn or-Duser. language = en to-Duser. language = zh-cn;
2. Modify the jar information of eclipse and MyEclipse plug-ins.
If the format is Mar 21,201 1, change it to 2011-3-21.
Modify the jar package org. eclipse. text_3.3.0.v20070606-0010.jar in eclipse/plugins (org. eclipse. text_XXXX.jar package), some versions are different dates after v.
The source code of this jar package can be downloaded here.
Modify the org. eclipse. jface. text. templates. GlobalTemplateVariables class and find the code:
Code public static class Date extends SimpleTemplateVariableResolver {/*** Creates a new date variable */public Date () {super ("date", TextTemplateMessages. getString ("GlobalVariables. variable. description. date "); // $ NON-NLS-1 $ // $ NON-NLS-2 $} protected String resolve (TemplateContext context) {return DateFormat. getDateInstance (). format (new java. util. change Date () ;}}
Code public static class Date extends SimpleTemplateVariableResolver {/*** Creates a new date variable */public Date () {super ("date", TextTemplateMessages. getString ("GlobalVariables. variable. description. date "); // $ NON-NLS-1 $ // $ NON-NLS-2 $} protected String resolve (TemplateContext context) {// return DateFormat. getDateInstance (). format (new java. util. date (); final SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd"); // return df in your format. format (new java. util. date ());}}
After the change, package it into a jar file again to overwrite the jar file in the original eclipse/plugins. Download of this file is also available online: org.eclipse.text_3.3.0.v20070606-0010.zip (230.1 KB)