Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.NumberFormat;

public class Main {
    /**
     * 
     * @param value
     * @param min_fraction_digit
     * @param max_fraction_digit
     * @return
     */
    public static String formatNumber(double value, int min_fraction_digit, int max_fraction_digit) {
        NumberFormat nf;
        nf = NumberFormat.getInstance();

        if (min_fraction_digit != 0) {
            nf.setMinimumFractionDigits(min_fraction_digit);
        }

        if (max_fraction_digit != 0) {
            nf.setMaximumFractionDigits(max_fraction_digit);
        }

        return nf.format(value);
    }
}