Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.DecimalFormat;

public class Main {

    public static String convertNumberToString(Number value, String pattern) {
        String s = null;
        try {
            if (pattern == null) {
                pattern = "###########0.00";
            }
            DecimalFormat decimalFormat = new DecimalFormat(pattern);
            s = decimalFormat.format(value);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return s;
    }
}