Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 213533 Details for
Bug 75981
[templates][preferences] Allow to specify format of date variable in templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch as described in comment 31.
eclipse75981.patch (text/plain), 2.81 KB, created by
Thomas Reinhardt
on 2012-04-03 16:52:57 EDT
(
hide
)
Description:
Patch as described in comment 31.
Filename:
MIME Type:
Creator:
Thomas Reinhardt
Created:
2012-04-03 16:52:57 EDT
Size:
2.81 KB
patch
obsolete
>diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java >index 19f27f6..abb8bae 100644 >--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java >+++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java >@@ -11,7 +11,11 @@ > *******************************************************************************/ > package org.eclipse.jface.text.templates; > >+import java.util.List; >+import java.util.Locale; >+ > import com.ibm.icu.text.DateFormat; >+import com.ibm.icu.text.SimpleDateFormat; > import com.ibm.icu.util.Calendar; > > /** >@@ -113,9 +117,36 @@ > 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 void resolve(TemplateVariable variable, TemplateContext context) { >+ List params= variable.getVariableType().getParams(); >+ >+ Locale locale=Locale.getDefault(); >+ if (params.size()>=2) { >+ String localeString= (String)params.get(1); >+ String[] localeParts=localeString.split("_"); //$NON-NLS-1$ >+ if (localeParts.length==1) { >+ locale= new Locale(localeParts[0]); >+ } else if (localeParts.length==2) { >+ locale= new Locale(localeParts[0], localeParts[1]); >+ } else { >+ throw new IllegalArgumentException(localeString); >+ } >+ } >+ >+ DateFormat format; >+ if (params.size()>=1) { >+ format= new SimpleDateFormat((String)params.get(0), locale); >+ } else { >+ format= DateFormat.getDateInstance(DateFormat.MEDIUM, locale); >+ } >+ >+ variable.setValue(format.format(new java.util.Date())); > } >+ >+ >+ >+ > } > > /** >diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TextTemplateMessages.properties b/org.eclipse.text/src/org/eclipse/jface/text/templates/TextTemplateMessages.properties >index a2549f0..737629a 100644 >--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TextTemplateMessages.properties >+++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/TextTemplateMessages.properties >@@ -17,7 +17,7 @@ > # global variables > GlobalVariables.variable.description.cursor=The cursor position after editing template variables > GlobalVariables.variable.description.dollar=The dollar symbol >-GlobalVariables.variable.description.date=Current date >+GlobalVariables.variable.description.date=Current date. Use ${id\:date(pattern [ , locale ])} to format the output. > GlobalVariables.variable.description.year=Current year > GlobalVariables.variable.description.time=Current time > GlobalVariables.variable.description.user=User name
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review-
Actions:
View
|
Diff
Attachments on
bug 75981
:
98429
| 213533 |
235875
|
235894