import java.text.NumberFormat; public class Main { public static void main(String[] argv) throws Exception { NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); System.out.println("Format with two decimal places: " + nf.format(1234567.678)); } }