Community
Participate
Working Groups
The locale used to format the variables of the Java Code Templates is always the locale of the current machine and can not be overridden. A possible workaround on Unix could be to set environment variables (LC?) in the batch which you use to start eclipse. There is no such environment variable on Windows AFAIK. This is an issue for international projects where development is done all over the world, and thus the date which gets inserted into the comments is formatted differently depending on the developer who did the specific update. Same problem, different company: http://dev.eclipse.org/newslists/news.eclipse.platform/msg25683.html Eclipse developers do not notice this as they never put the current date into the sources (of Eclipse itself, AFAIK). In fact, ${date} and ${time} could be a nice feature, but is currently not usable for us. Thank you for the whole thing, nevertheless - Eclipse is great.
Implementing this would need parameterizable template variables. You could then have a template such as this: ${date,en_US} or ${date,en_US,yyyy/mm/dd} See also bug 10694 on a related problem (type constraints for template variables).
There's an Eclipse command line argument for this: -nl <locale>
Daniel Megert, you are right - according to what I have written, the command line argument -nl actually solves the problem; all developers can use a common locale and thus the date will always be formatted identically. But what I have meant is that I know no way to specify that Eclipse should format a date as yyyy/mm/dd - except by changing the locale to China/Chinese, and this may have unwanted other effects as I can not read Chinese ;-). Java is ignoring the Windows XP settings, where I specified that my Locale is German but nevertheless dates have to be formatted as yyyy/MM/dd. I assume the proposal from Tom P. Eicher ${date,en_US,"yyyy/mm/dd"} could be too complicated to implement as general and clean solution. At least it needs much documentation which parameters can be put on what variable. I am thinking in the direction that the Preferences for Java Code Templates could get a third sub-tree "Variables" in addition to "Comments" and "Code", where it would be possible e.g. to specify how ${todo} should look like, the full ${user} name (which e.g. for me differs significantly from the login name), and, ultimately, the format strings for date and time.
>and this may have unwanted other effects as I can not read Chinese ;-). Assuming you installed the language pack you could simply remove those language that you do not understand :-) >${todo} should look like This stands for the default todo tag - not sure what you would want to configure here. >full ${user} name ( This can be specified when starting Eclipse - no plans to add this. We could add preferences for the data and time format variables.
Being able to define the order of ${date} and ${time} is useful as a preference, because sometimes code is written by people in different geographical locations and there may be a coding standard that all dates are represented as ISO standard (2005-12-31). The 'best' solution would be to have a preference that is globally sharable without having to change individual PCs time/date settings or invoke with special arguments; after all, that's exactly what happens with other coding standards (such as indentation). If that's too difficult to implement, it could also be solved with the provision of ${day} ${month} ${year} variables, and thus people can hard-code templates to whatever format they want. There might however be arguments as to whether the values should be zero-prefixed or words instead of numbers, but in the spirit of internationalisation (and because it's easier) I think numbers would satisfy. I would suggest that a zero-prefixed 24h is used by default in case external tools need to be able to parse on position instead of delimiter.
*** This bug has been marked as a duplicate of 75981 ***