Tuesday, May 22, 2012

Difficulty parsing a double - String

Thanks for taking the time to answer my question.



I have a double value (let's say 22.35). I need to parse it into a String and get 2235. The following code is not working properly.



double totalPrice = 22.35;
DecimalFormat df = new DecimalFormat("#.##");
String[] temp = df.format(totalPrice).split(".");
String amount = temp[0] + temp[1];


I keep getting an exception ArrayIndexOutOfBounds. What is another way to do this? Thanks in advance!





No comments:

Post a Comment