Look at the DecimalFormat class.