cancel
Showing results for 
Search instead for 
Did you mean: 

Currency Problem

Former Member
0 Kudos

Hi,

I have a Model Node of an RFC BAPI.

There is one attribute of type currency.

Now I want to display that amount it should automaticly

return that currency amount to in the right format. ('200.034,10' for example)

But now I get it like this: '200.034,1'

I tried to use:


Double currency = new Double(200034.1);
NumberFormat.getCurrencyInstance(Locale.GERMANY);
currencyOut = currencyFormatter.getNumberInstance().format(currency);

Now I get the right format but with the Currency Symbol as String ('200.034,10 <b>€</b>')

I don't want to have the <b>€</b>. Is there any way to resolve that?

Thanks and best Regards,

Dennis

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Dennis,

just note that if you use split you wouldn´t be able to catch for example $ that is at the begin of the string.

So why don´t you use a regular expression for this? you could replace everything but dots, comma and numbers.

Sergio

Former Member
0 Kudos

Hi Dennis,

as far as I know you cannot avoid having the money symbol using method getCurrencyInstance.

Just if you always use the same rule of conversion couldn´t you use getNumberInstance specifing how you want the number to be formatted.

Instead if you do not use the same Locale than you could for example split the string on spaces and always take the first part of the split.

Hope it helps,

Regards,

Sergio

Former Member
0 Kudos

Hi Lars,

I had that Idea before. But is not that kind of easy.

Sometimes I get the currency in € sometimes in USD, Jen or whatever.

It's totally dynamic.

I could write a new class to catch all possibilities, but I think that is

to time consuming and I don't want to do that

Any other ideas?

Former Member
0 Kudos

you cut chop of all the parts of the sting after the space, this should work fine and you don't have to check all possible currency-cases

former_member182294
Active Contributor
0 Kudos

Hi Dennis,

You can use the same idea with out much effort. Try the following...

> Get the Current Locale Symbol using

<b>currencyFormatter.getCurrency().getSymbol()</b>

<b>currencyFormatter.getCurrency().getSymbol(Locale.GERMANY)</b>

> Use String replace function to replace the value which is dynamic always.

Regards

Abhilash

Former Member
0 Kudos

Please see:

<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#replace(char,%20char)">String.Replace in JavaDoc</a>