Eclipse/myeclipse date format, comment date format, time zone problem

Source: Internet
Author: User
Tags dateformat static class

In Eclipse/myeclipse, if you comment or run System.out.print (new Java.util.Date ()), the time and system difference is found to be 8 hours.

You can then indicate that your time zone does not correspond to the current time zone. The time zone we use in China is Asia/shanghai, you should be in the East eight area for 8 hours. On this point

You don't know, you can look at junior high geography: D.

There are 2 ways to solve the problem:

1. Set the time zone in the JRE run parameter of your eclipse/myeclipse JVM. Set in default VM arguments:-duser.timezone=asia/shanghai

Step: In window->preferences->java->installed jers then see the installation list on the right with the JRE, select one, click Edit,

Then set in default VM arguments:-duser.timezone=asia/shanghai

Click Finish, restart Eclipse, MyEclipse;

2, the reason for this time zone difference is that the system's software registry time zone settings are corrupted, re-registration can be

Javaeye is also available on the registration form download: Time_zones_xp.rar

Run the registry after decompression should be ready

In Eclipse/myeclipse, if you find that your comments are in English format (Mon Mar 10:57:13 CST 2011), instead of the Chinese format or the format you want, you can do so in the following ways.

1, in Eclipse.ini, myeclipse.in configuration file to add-DUSER.LANGUAGE=ZH-CN or-duser.language=en change to-DUSER.LANGUAGE=ZH-CN can;

2. Modify the jar information of Eclipse and MyEclipse plugin.

The format is: Mar 21, 2011; Want to change to: 2011-3-21

So modify the Org.eclipse.text_3.3.0.v20070606-0010.jar in Eclipse/plugins this jar package (Org.eclipse.text_XXXX.jar package), some versions are different from the date after V.

The source code for this jar package can be downloaded here: Http://wiki.eclipse.org/index.php/CVS_Howto Download the source of Eclipse, mainly download the class under the Org.eclipse.text package.

Then modify the Org.eclipse.jface.text.templates.GlobalTemplateVariables class to find the 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 ());}}
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");  Your format return Df.format (New Java.util.Date ());}  }

Eclipse/myeclipse date format, comment date format, time zone problem

Related Article

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.