Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Where are the resources used by NumberFormat?

Thread view: 
Scott Smith - 26 Feb 2007 18:01 GMT
I need to format percentages for 23 different locales, and unfortunately my
client doesn't use Java. If I recall correctly, in Java I'd use
NumberFormat.getPercentInstance(locale) [or something like that], and the
JRE would get the appropriate percent formatting info from a locale-specific
resource bundle.

OK, so... where are those resources?  I basically need to do something
similar in a non-Java program, and I want to avoid having to research the
percent formats for 23 different locales.

I've done some searching, but haven't been able to find them.  Can someone
point me in the right direction?

Thanks in advance.

-Scott
Thomas Fritsch - 26 Feb 2007 18:54 GMT
> I need to format percentages for 23 different locales, and unfortunately
> my client doesn't use Java. If I recall correctly, in Java I'd use
[quoted text clipped - 8 lines]
> I've done some searching, but haven't been able to find them.  Can someone
> point me in the right direction?

Looking into the source "NumberFormat.java" I find
   ResourceBundle resource = LocaleData.getLocaleElements(desiredLocale);
where class LocaleData is imported from package "sun.text.resources".
I assume this call loads resources that same package.
In file "<jre>/lib/rt.jar" there are many files
   sun/text/resources/LocaleElements_<locale>.class
for european locales. And in file "<jre>/lib/ext/localedata.jar" there are
some more for asian locales.

Signature

Thomas

mr.intj@gmail.com - 01 Mar 2007 07:33 GMT
On Feb 26, 10:54 am, Thomas Fritsch <i.dont.like.s...@invalid.com>
wrote:
> ScottSmithwrote:
> > I need to format percentages for 23 different locales, and unfortunately
[quoted text clipped - 21 lines]
> --
> Thomas

Thomas,

Thanks very much. Found everything I needed!

-Scott
Chris Uppal - 26 Feb 2007 18:57 GMT
> I need to format percentages for 23 different locales, and unfortunately
> my client doesn't use Java. If I recall correctly, in Java I'd use
[quoted text clipped - 5 lines]
> similar in a non-Java program, and I want to avoid having to research the
> percent formats for 23 different locales.

A)  I should check the licensing position very carefully before using Sun's IP
in a non-Java application.

B) I think it depends on the Locale service provider.

C) Why not just dump the data out of Java with a loop over
NumberFormat.getAvailableLocales(), calling getPercentInstance() on each one ?

D) The data included with the jre is in <jre>/lib/ext/localedata.jar.  Inside
the jar, the resource bundles are sun/text/resources/FormatData_*.class.

E) The source for that isn't included in src.zip (further evidence that Sun
regard this data as part of their private IP).

F) The source /is/ included in the platform source download (hedged about by
licencing restrictions).

G) I would be willing to bet that the data for Java's number format stuff was
supplied by IBM, and their code is available as the (impressive) ICU library
for C, C++. and Java.
    http://icu.sourceforge.net/userguide/intro.html

   -- chris
mr.intj@gmail.com - 01 Mar 2007 07:36 GMT
On Feb 26, 10:57 am, "Chris Uppal" <chris.up...@metagnostic.REMOVE-
THIS.org> wrote:
> ScottSmithwrote:
> > I need to format percentages for 23 different locales, and unfortunately
[quoted text clipped - 30 lines]
>
>     -- chris

Chris,

Thanks for the detailed reply. I was able to find the information that
I needed with your help and the JAD decompiler. Someone could make a
case about the IP issue, but I was looking at it more for reference
than to lift code. Turns out that the percent formats are the same for
all of the locales that I was interested in. Good to know.

-Scott


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.