Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

currency preference API

1 view
Skip to first unread message

Roedy Green

unread,
Oct 1, 2011, 1:22:08 PM10/1/11
to
I think if would be useful if Java had a currency API.

The basic feature a user.currency property that is the 3-char ISO code
for the preferred currency taken from the OS or inferred from the user
country. It might also work like Locales, or be an extra field in
Locale.

Also it would be nice if there were a transparent mechanism to tell
you the conversion rates. If you had access to the Internet, it would
automatically retrieve the data from Oracle once a day. Otherwise you
would need to mechanism to walk the date into Java's isolated from the
net.

This would be used for displaying prices in user units on websites.
Currency speculators want various flavours of exchanges and up to the
second data, like a stock ticker. I don't think Oracle should worry
too much about that, though they might to a JavaMail style plugable
interface definition for fancy stuff.
--
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

Stanimir Stamenkov

unread,
Oct 1, 2011, 1:51:00 PM10/1/11
to
1.10.2011 г. 20:22 ч., /Roedy Green/:
> I think if would be useful if Java had a currency API.
>
> The basic feature a user.currency property that is the 3-char ISO code
> for the preferred currency taken from the OS or inferred from the user
> country. It might also work like Locales, or be an extra field in
> Locale.

Doesn't java.util.Currency provide just that?

http://download.oracle.com/javase/6/docs/api/java/util/Currency.html

Currency defaultCurrency = Currency.getInstance(Locale.getDefault());
defaultCurrency.getCurrencyCode();
defaultCurrency.getNumericCode();

> Also it would be nice if there were a transparent mechanism to tell
> you the conversion rates. If you had access to the Internet, it would
> automatically retrieve the data from Oracle once a day. Otherwise you
> would need to mechanism to walk the date into Java's isolated from the
> net.

Exchange rates greatly vary depending on the institution you would
trade the currency from, so I don't think such built-in service
will ever be made available. Institutions which need to rely on
such service usually pay for a subscription.

> This would be used for displaying prices in user units on websites.
> Currency speculators want various flavours of exchanges and up to the
> second data, like a stock ticker. I don't think Oracle should worry
> too much about that, though they might to a JavaMail style plugable
> interface definition for fancy stuff.

For display purposes there's java.util.NumberFormat:

NumberFormat.getCurrencyInstance()
NumberFormat.getCurrencyInstance(Locale)

--
Stanimir

Roedy Green

unread,
Oct 1, 2011, 7:42:09 PM10/1/11
to
On Sat, 01 Oct 2011 20:51:00 +0300, Stanimir Stamenkov
<s7a...@netscape.net> wrote, quoted or indirectly quoted someone who
said :

>Exchange rates greatly vary depending on the institution you would
>trade the currency from, so I don't think such built-in service
>will ever be made available. Institutions which need to rely on
>such service usually pay for a subscription.

The bank of Canada provides the information free. They post the rates
once a day. See http://mindprod.com/applet/currcon.manual.html for
sources. There may be various such services that Oracle could use
free, to create its own compact binary representation. It might not be
all that expensive for Oracle to subscribe to a couple of services for
rebroadcast. It is not that big a list. In a pinch it could hire
someone to type them in from the newspaper or other sources.

My idea is that internationalisation, even for web apps should be
routine, not require everyone reinventing the wheel..

Roedy Green

unread,
Oct 1, 2011, 7:45:31 PM10/1/11
to
On Sat, 01 Oct 2011 20:51:00 +0300, Stanimir Stamenkov
<s7a...@netscape.net> wrote, quoted or indirectly quoted someone who
said :

>http://download.oracle.com/javase/6/docs/api/java/util/Currency.html
>
> Currency defaultCurrency = Currency.getInstance(Locale.getDefault());
> defaultCurrency.getCurrencyCode();
> defaultCurrency.getNumericCode();

I invented my own logic for this way back, which now has stopped
working since Java now thinks my locale is the USA not Canada, even
though my Windows 7 locale is Canada.

I either did not notice or forgot. That is just what I wanted.
Thanks.

Stanimir Stamenkov

unread,
Oct 2, 2011, 3:44:31 AM10/2/11
to
Sat, 01 Oct 2011 16:42:09 -0700, /Roedy Green/:
> On Sat, 01 Oct 2011 20:51:00 +0300, Stanimir Stamenkov
> <s7a...@netscape.net> wrote, quoted or indirectly quoted someone who
> said :
>
>> Exchange rates greatly vary depending on the institution you would
>> trade the currency from, so I don't think such built-in service
>> will ever be made available. Institutions which need to rely on
>> such service usually pay for a subscription.
>
> The bank of Canada provides the information free. They post the rates
> once a day. See http://mindprod.com/applet/currcon.manual.html for
> sources.

But then this information is specific to bank of Canada. If you go
to trade currency in Europe, for example, the exchange rates will be
different enough that in some situations may be considered just wrong.

> There may be various such services that Oracle could use
> free, to create its own compact binary representation. It might not be
> all that expensive for Oracle to subscribe to a couple of services for
> rebroadcast. It is not that big a list. In a pinch it could hire
> someone to type them in from the newspaper or other sources.
>
> My idea is that internationalisation, even for web apps should be
> routine, not require everyone reinventing the wheel..

If a standards organization comes up with an interface to obtain
such information from services which support it, I guess Oracle
could include suitable API, which could well be made available as a
standard extension, for starters. But again, I don't think such
thing will be standardized anytime soon, let alone Java API
available for it.

--
Stanimir

Roedy Green

unread,
Oct 9, 2011, 11:11:21 PM10/9/11
to
On Sun, 02 Oct 2011 10:44:31 +0300, Stanimir Stamenkov

<s7a...@netscape.net> wrote, quoted or indirectly quoted someone who
said :

>But then this information is specific to bank of Canada. If you go

>to trade currency in Europe, for example, the exchange rates will be
>different enough that in some situations may be considered just wrong.

I would think that people would just trade in some other country then
trade back, which would pull the exchange rates into sync.

0 new messages