That's alot of work so far for working on formatting decimals into 2 spaces.
What I would do is...
for a number example: 52.33950258
double amount = 52.22950158;
String s = ""+amount+"";
String beforeDecimal = s.split("\\.")[0];
String afterDecimal = s.split("\\.")[1].substring(0,2);
s = beforeDecimal+"."+afterDecimal;
System.out.println(s);
Result: 52.22
If you want to round, do
String 3rddigit = s.split("\\.")[1].substring(2,3);
if(integer.parseint(3rddigit) > 5){
afterdecimal = afterdecimal.substring(0,1)+(integer.parseint(afterdecimal.substring(1,2)+1));
}
To be honest, if you want to get a more accurate decimal round, I average each decimal space after the 2 you show as a result.
If those spaces don't average more than 5, I wouldn't round it. But that's quite a bit of code. You could condense it in a for loop though.