Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 169418 - Localized Date in Code Templates
Summary: Localized Date in Code Templates
Status: RESOLVED DUPLICATE of bug 75981
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-03 07:20 EST by Mohsen Saboorian CLA
Modified: 2007-01-04 06:11 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mohsen Saboorian CLA 2007-01-03 07:20:54 EST
1. In Java Code Templates, I have a ${date} added to my new classes. But since
every date in Eclipse (tested in 3.3M4) is in localized (Unicode) format, and
my default Character encoding is Cp1256, "New Java Class" fails, giving:
Creation of elements failed.
Reason: Some characters cannot be mapped using "Cp1256" character encoding...

Is there any option to have ${date} in default ASCII format?

2. Just out of my curiosity :). How did you encoded numbers in date to localized
format. I searched all java.text.* (Formatters, ...) to find something for
doing that. Is there any class library for this in JDK, or you used a
third-party?
Comment 1 Martin Aeschlimann CLA 2007-01-03 10:14:07 EST
- The locale of your machine decides how the date string is formatted: 11/3/06 or 20061102 or whatever. The result is a Java 'String' that can contain all possible Unicode characters
- The character encoding decides how the Java string is written to a file

It seems your system have a local configured that produces date starings that are not compatible with the character encoding your team or project requires.
To change the local: change the locale in the OS or use command line parameters for eclipse
To change the encoding: Property page on files or projects

The date variable is provided by platform.text. We could allow you to provide a specific locale with the date variable: something like ${date:US_en}
Comment 2 Dani Megert CLA 2007-01-03 10:27:18 EST

*** This bug has been marked as a duplicate of bug 75981 ***
Comment 3 Mohsen Saboorian CLA 2007-01-04 06:11:38 EST
> - The locale of your machine decides how the date string is formatted: 11/3/06
> or 20061102 or whatever. The result is a Java 'String' that can contain all
> possible Unicode characters
This is good to have localized date for ${date} variable, but user might not always need to have a locale specific date format in a Java code.

> It seems your system have a local configured that produces date starings that
> are not compatible with the character encoding your team or project requires.

Actually, Windows default encoding for fa_XX or ar_XX is Cp1256 (which is an 8-bit charset). But Eclipse decides to provide date in Unicode (UTF-8 I think) format, ignoring my default encoding (file.encoding system property).

> specific locale with the date variable: something like ${date:US_en}

Martin, is this possible by now? I could not change ${date} to ${date:US_en} on my 3.3M4 (I20061214-1445) build. It complains: "variable en_US is unknown".