I am using Java (for my sins) and want to display a number to always use three characters, but no joy.
Some snippets of what I have tried...
Code:
String msg = MessageFormat.format("{0,number,##0}%", (double) _size
* TO_PERCENTAGE / containerSize);
Code:
NumberFormat percent = NumberFormat.getPercentInstance();
String msg = percent.format((double)_size * TO_PERCENTAGE / containerSize);
Code:
DecimalFormat decimal = new DecimalFormat("##0");
String msg = decimal.format(_size * TO_PERCENTAGE / containerSize)
+ "%";
Each work the same, which is print the number but left aligned without the spaces that I yearn for.
Is there any way to entice this behaviour out of the Format family of classes or do I have to do the padding myself?