There are a couple of methods (the DecimalFormat format class and the various printf() and format() methods) described on the Formatting Numeric Print Output page of Oracle's Tutorial.