| Summary: | [preference] Add option to specifiy format of ${date} and ${time} variables | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Christian Spreuer <guest.icm-n-pg-nm-sc-b4> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P4 | Keywords: | helpwanted |
| Version: | 3.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Christian Spreuer
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.
|