• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1218

# convert from string to decimal

folks below i have code , but it is supposed to be a decimal and not a string

how do i successfullly convert this
``````String charge =mbo.getString("LOCATIONSPEC-RATE.NUMVALUE");
if (charge==null) charge ="" ;
mbo.setValue("costs", charge);
``````
0
rutgermons
• 3
• 2
• 2
• +1
1 Solution

Commented:
Use
Float.parseFloat(charge);
0

Commented:
String charge =mbo.getString("LOCATIONSPEC-RATE.NUMVALUE");
if (charge==null) charge ="" ;
mbo.setValue("costs", Float.parseFloat(charge));

http://vpgupta.blogspot.com/2006/09/difference-between-xxxvalue-parsexxx.html
0

Author Commented:
whats the solution then?
0

Commented:
mbo.setValue("costs", Float.parseFloat(charge));   ---> ?

Can you explain the question in detail ? What is the expected output with example ?
0

Author Commented:
LOCATIONSPEC-RATE.NUMVALUE is actually a decimal value

and the output should be decimal too
0

Commented:
>>LOCATIONSPEC-RATE.NUMVALUE is actually a decimal value

In that case, why not do the following? Obviously, i don't know the type and methods of 'mbo'. If i did, i could help you more precisely

``````mbo.setValue("costs", mbo.getDouble("LOCATIONSPEC-RATE.NUMVALUE"));
``````
0

Commented:
sounds like it should be this:

mbo.setValue("costs", mbo.getValue("LOCATIONSPEC-RATE.NUMVALUE"));

Let me know what mbo is and I'll check it for you.

0

Commented:
:-)
0

## Featured Post

• 3
• 2
• 2
• +1
Tackle projects and never again get stuck behind a technical roadblock.