Java Long Number Format comma(long n)

Here you can find the source of comma(long n)

Description

Copied from com.shopwiki.text.Pretty

License

Apache License

Declaration

public static final String comma(long n) 

Method Source Code

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

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    private static final ThreadLocal<NumberFormat> numberFormat = new ThreadLocal<NumberFormat>() {
        @Override/*from   www . j  a  v a2  s . c  o  m*/
        protected NumberFormat initialValue() {
            return new DecimalFormat();
        }
    };

    /** Copied from com.shopwiki.text.Pretty */
    public static final String comma(long n) {
        return numberFormat.get().format(n);
    }

    /** Copied from com.shopwiki.text.Pretty */
    public static final String comma(double n) {
        return numberFormat.get().format(n);
    }
}

Related

  1. format(final long number, final int length)
  2. format(final long value, final long divider, final String unit)
  3. format(final long value, final long divider, final String unit)
  4. format(long bytes)