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

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);

Open in new window

0
rutgermons
Asked:
rutgermons
  • 3
  • 2
  • 2
  • +1
1 Solution
 
basav_comCommented:
Use
Float.parseFloat(charge);
0
 
basav_comCommented:
String charge =mbo.getString("LOCATIONSPEC-RATE.NUMVALUE");
                if (charge==null) charge ="" ;
                mbo.setValue("costs", Float.parseFloat(charge));


Check this parseXXX() link:
http://vpgupta.blogspot.com/2006/09/difference-between-xxxvalue-parsexxx.html
0
 
rutgermonsAuthor Commented:
whats the solution then?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Can you explain the question in detail ? What is the expected output with example ?
0
 
rutgermonsAuthor Commented:
LOCATIONSPEC-RATE.NUMVALUE is actually a decimal value

and the output should be decimal too
0
 
CEHJCommented:
>>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"));

Open in new window

0
 
objectsCommented:
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
 
CEHJCommented:
:-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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