Sam Su
Sam Su

Reputation: 6832

Unexpected Java code comments generated by Eclipse Code Templates?

As we know,Eclipse can help us generate code comments for types and methods,e.g,we can go
Preferences > Java > Code Style > Code Templates > Comments to configure a template for Java types.
Here is my template for Types:

/**
 * @className:${package_name}.${file_name}
 * @description:${todo}
 * @author <a href="mailto:[email protected]">Author</a>
 * @date ${date} ${time}
 */

Well when I press / * * and Enter before a class type,the Eclipse will generate comments below:

/**
 * 
 * @className:com.abc.demo.Demo.java
 * @description:TODO
 * @author <a href="mailto:[email protected]">Author</a>
 * @date May 26, 2013 8:56:12 AM
 */

In fact,there are two things which are not what I expected.

  1. There is a blank line before @className,so everytime I have to press ctrl + D to delete it;
  2. The date format is not what I expected(I wish it could be 2013-05-26 but it is May 26, 2013),and what’s even weirder is,the time is not correct(or Not my timezone's current time?)

So can it really generated code templates as I will below:

/**
* @className:com.abc.demo.Demo.java
* @description:TODO
* @author <a href="mailto:[email protected]">Author</a>
* @date 2013-05-26 09:30 PM
*/

btw,I am working on Windows 7 with Eclipse Helios.

Upvotes: 1

Views: 1239

Answers (1)

Michael Zilbermann
Michael Zilbermann

Reputation: 1428

About the date formatting, have a look at this SO entry : How to set the Eclipse date variable format?

In short, setting "-Duser.language" and "-Duser.region" may help.

Upvotes: 1

Related Questions