on 11-23-2006 12:17 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.