format Double - Java java.lang

Java examples for java.lang:double Format

Description

format Double

Demo Code


//package com.java2s;

import java.text.NumberFormat;

public class Main {
    public static void main(String[] argv) throws Exception {
        double number = 2.45678;
        System.out.println(formatDouble(number));
    }//from  ww w . j ava2s .  c  o  m

    public static final NumberFormat NUMBER_FORMAT = NumberFormat
            .getInstance();

    public static String formatDouble(double number) {
        return NUMBER_FORMAT.format(number);
    }
}

Related Tutorials