String converting into Currency(Double)

View: New views
2 Messages — Rating Filter:   Alert me  

String converting into Currency(Double)

by nani2ratna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I want to convert String to Currency.
But i get the string in different formats.
For example sometimes I get 1,158.67 and sometimes i get 1158.67.
Both strings in need to convert to double by using parseDouble.

Is there any util methods for this.

Thanks and Regards
RS.K

Re: String converting into Currency(Double)

by Hagen Bognitz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

you can tried like this:
<code>
String input = "1,158.67"; // your input string
String modString = input.replace( ",", "" );
System.out.println( modString );
</code>

Output: 1158.67

now you can parse it to double.