Java Number Format Pattern format(Integer num)

Here you can find the source of format(Integer num)

Description

format

License

LGPL

Declaration

public static String format(Integer num) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class Main {
    static String numericFormat = "#,##0.00";

    public static String format(Double num) {
        String result = "";
        try {/* w  w  w. j a  va2  s .  com*/
            result = new DecimalFormat(numericFormat).format(num);
        } catch (Exception e) {
            // TODO: handle exception
        }
        return result;
    }

    public static String format(Integer num) {
        String result = "";
        try {
            result = format((double) num);
        } catch (Exception e) {
            // TODO: handle exception
        }
        return result;
    }

    public static String format(String num) {
        String result = "";
        try {
            result = format(Double.parseDouble(num));
        } catch (Exception e) {
            // TODO: handle exception
        }
        return result;
    }

    public static String format(BigDecimal num) {
        String result = "";
        try {
            result = format(num.doubleValue());
        } catch (Exception e) {
            // TODO: handle exception
        }
        return result;
    }
}

Related

  1. createOrderVolumeNumberFormat()
  2. createRealFormat()
  3. expFormatRupiah(Number input, boolean prependRp)
  4. format(final long l)
  5. format(final long value, final long divider, final String unit)
  6. format(long bytes)
  7. format(long value)
  8. format(Number value)
  9. format(Number value)