in Java 7, I need to perform multiple formatting operations on a double before further processing it. I currently do it like so:
double price = lemon.getPrice(); // Something like 20.2 or 19.235
String priceWith2Digits = String.format("%.02f", price); // 20.20
String priceWithDecimalComma = priceWith2Digits.replace('.', ','); // 20,20
String pricePadded = selfMadePaddingFunction(priceWithDecimalComma, 10, ' '); // " 20,20"
result.setPrice(pricePadded);
Now I wonder if there is a way to increase readability while reducing the number of String variables.
Edit: This question is not about padding, its about increasing code readability, which is not done by doing everything in one row.