cancel
Showing results for 
Search instead for 
Did you mean: 

String to Decimal

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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.