Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Where are the resources used by NumberFormat?

Reply
Thread Tools

Where are the resources used by NumberFormat?

 
 
Scott Smith
Guest
Posts: n/a
 
      02-26-2007
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



 
Reply With Quote
 
 
 
 
Thomas Fritsch
Guest
Posts: n/a
 
      02-26-2007
Scott Smith wrote:

> 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?


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.

--
Thomas
 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      02-26-2007
Scott Smith wrote:

> 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.


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


 
Reply With Quote
 
mr.intj@gmail.com
Guest
Posts: n/a
 
      03-01-2007
On Feb 26, 10:54 am, Thomas Fritsch <(E-Mail Removed)>
wrote:
> ScottSmithwrote:
> > 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?

>
> Looking into the source "NumberFormat.java" I find
> ResourceBundleresource = 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.
>
> --
> Thomas


Thomas,

Thanks very much. Found everything I needed!

-Scott

 
Reply With Quote
 
mr.intj@gmail.com
Guest
Posts: n/a
 
      03-01-2007
On Feb 26, 10:57 am, "Chris Uppal" <(E-Mail Removed)-
THIS.org> wrote:
> ScottSmithwrote:
> > 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.

>
> 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


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resources I used for 70 271 exam Robyn MCDST 3 03-12-2007 07:46 AM
py2app question: Resources/Python -> Resources/lib/python2.4 Russell E. Owen Python 0 09-08-2006 08:08 PM
IOS command to view resources used on router? SJ Cisco 6 04-07-2005 01:46 PM



Advertisments