I have element-level comments in my code & I need to say when was the last time I modified a piece of code. Since it might be difficult to do this automatically when I save the document in question, I was looking for some semi-automatic solution where I press a shortcut & poof the date/time appears at my cursor.
E.g.
/**
* modified by @author Chantz last on <ENTER CURRENT DATE TIME HERE>
*/
public class EclipsePrintDateTimePlease {
...
UPDATE Eclipse versions I use are Helios & Galileo (I have different workstations).
The
date
variable in comment templates supports a format.From the context help:
So setting a template to:
will result in a comment like:
Preferences --> Java --> Code Style --> Code Templates
Then press Shift + Alt + J will help you add date and time in existing file.
You didn't specify which version of Eclipse you're using but, unless you are on a very old version, this should work:
All the previous posts are correct:
Write a template for a keyword, for example date, that uses Eclipse date and time variables. After doing this, you will be able to expand the keyword into a date with Ctrl-Space.
For details, have a look at http://www.ibm.com/developerworks/opensource/library/os-eclipse-galcode/index.html
However, what you probably want instead is putting your code into some sort of versioning system (Subversion, git, Hg, ...) and use their capabilities to keep track on your versions and when you checked them in.
///BR, Jens Carlberg