Java Number Format Pattern formatIncludeCommas(final Number object)

Here you can find the source of formatIncludeCommas(final Number object)

Description

Format numbers for display as comma separated groups.

License

Open Source License

Parameter

Parameter Description
object Contains the value that needs to be converted.

Return

Returns comma separated formatted values.

Declaration

public static String formatIncludeCommas(final Number object) 

Method Source Code


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

public class Main {
    /**//  ww w.ja  va  2s.  c o m
     * Holds reference to the US Decimal formatter.
     */
    private static final DecimalFormat NUMBER_FORMATTER = new DecimalFormat("###,###,###");

    /**
     * Format numbers for display as comma separated groups.
     * 
     * @param object
     *            Contains the value that needs to be converted.
     * @return Returns comma separated formatted values.
     */
    public static String formatIncludeCommas(final Number object) {
        if (object == null) {
            return "";
        }
        return NUMBER_FORMATTER.format(object);
    }
}

Related

  1. formatDollarTd(Object obj)
  2. formatFileLength(long length)
  3. formatGopNumber(Number gop)
  4. formatI18N(Object ob)
  5. formatiereSpeichergroesse(long bytes)
  6. formatInt(final int number)
  7. formatInteger(Object obj)
  8. formatIntoCurr(String str_number, int digits)
  9. formatLong(long value)