Format to Double Decimal - Java java.lang

Java examples for java.lang:double Format

Description

Format to Double Decimal

Demo Code


//package com.java2s;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

import java.util.Locale;

public class Main {
    public static void main(String[] argv) throws Exception {
        double paramInt = 2.45678;
        System.out.println(toDoubleDecimal(paramInt));
    }// w  w  w  .ja v a  2  s .  c  om

    private static DecimalFormat df = new DecimalFormat("#.##",
            DecimalFormatSymbols.getInstance(Locale.ENGLISH));

    /**
     * 
     * @param paramInt
     * @return
     */
    public static String toDoubleDecimal(double paramInt) {
        return df.format(paramInt);
    }
}

Related Tutorials