on 09-12-2007 10:22 AM
Hi,
What is the right way to map a Locale to a DateFormat object so that the mapping applies for all applications running on the j2ee engine?
Using DateFormat.getDateInstance(int style, Locale aLocale) one can get a DateFormat object for a certain Locale, but I didn't found any info on how to edit the mapping.
Thanks,
Jeroen
maybe
Locale.setDefault(Locale new) will work for you
see
<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Locale.html#setDefault(java.util.Locale)">Java Docs</a>
Franz
reward points if useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check following code.
Locale locale= new Locale("en");
DateFormat df= DateFormat.getDateInstance();
df.setNumberFormat(NumberFormat.getInstance(locale));
Ashu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeroen,
I guess the quickest way would be to decompile the sun.text.resources.LocaleElements_en_GB class which is part of the rt.jar (at least for the SUN VM; the mechanism might be different for other VMs), patch its getContents() method, compile your class and either patch the rt.jar file or prepend the bootclasspath with the path to where your modified class is compiled. You can use the -Xbootclasspath/p:<targetPath> option for that, but note that according to the Java 1.5 documentation that I have on my machine, SUN considers this against the Java binary code license (things might be different now with Java being Open Source, but IANAL).
Hope that helps you.
Best Regards,
Jens
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.