on 11-16-2007 1:12 PM
Hi,
I'm writing java class to do the mapping in XI. I'm geting in one field amount value as String, and need to do some tax, discount, etc. calculations over few rows for every document. What is the best way to convert String to some decimal format and then to perform calculations?
thx
Mario
Hi mario,
u can use this coding also.
Double.parseDouble(String num);
or Float.parseFloat(String num);
for eg
double aa =Double.parseDouble("0.45");
float aa1 =Float.parseFloat("0.45");
Hope this helpfull,
by,
Boopalan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mslopar,
try this code:
try{
java.text.DecimalFormat df = new java.text.DecimalFormat();
Number n = df.parse("2,5"); //Your string value
double value = n.doubleValue();
//... Your calculations
String string_result = df.format(n); //Result string value
}catch (Exception e){
//...
}
DecimalFormat constructor allows you to define various Location settings with respect of number format. For example decimal "," or "." and so on.
regards.
mz.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.