If the format is only relevant when displaying the data, use
DecimalFormat to get a formatted String representation of the double. The double value is just a number - it doesn't have a strict 'format' as such. As an example, 1.000000 and 1.0 are the exact same number.
If precision is important, use a
BigDecimal instead of a double.