format double value as US Locale - Java java.lang

Java examples for java.lang:double Format

Description

format double value as US Locale

Demo Code


//package com.java2s;
import java.text.NumberFormat;
import java.util.*;

public class Main {
    public static void main(String[] argv) throws Exception {
        double value = 2.45678;
        System.out.println(format(value));
    }/*from  ww  w  .j  av a2  s  . c  o m*/

    public static String format(double value) {
        return NumberFormat.getInstance(Locale.US).format(value);
    }

    public static void println(String s, Object... args) {
        System.out.printf(s + "\n", args);
    }
}

Related Tutorials