Java Number Format Pattern getFormattedInteger(int n)

Here you can find the source of getFormattedInteger(int n)

Description

Utility method to get an ineteger as a formatted string.

License

Open Source License

Parameter

Parameter Description
n the integer

Return

the formatted string

Declaration

public static String getFormattedInteger(int n) 

Method Source Code

//package com.java2s;
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
 *
 * Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
 *
 * For more information, contact:/*from  w  w  w . j  ava2  s. c  om*/
 *
 *   Generalitat Valenciana
 *   Conselleria d'Infraestructures i Transport
 *   Av. Blasco Ib??ez, 50
 *   46010 VALENCIA
 *   SPAIN
 *
 *   +34 963862235
 *   gvsig@gva.es
 *   www.gvsig.gva.es
 *
 *    or
 *
 *   Prodevelop Integraci?n de Tecnolog?as SL
 *   Conde Salvatierra de ?lava , 34-10
 *   46004 Valencia
 *   Spain
 *
 *   +34 963 510 612
 *   +34 963 510 968
 *   gis@prodevelop.es
 *   http://www.prodevelop.es
 */

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

public class Main {
    private static DecimalFormat df = new DecimalFormat();
    private static DecimalFormatSymbols dfs = new DecimalFormatSymbols();

    /**
     * Utility method to get an ineteger as a formatted string.
     * 
     * @param n
     *            the integer
     * @return the formatted string
     */
    public static String getFormattedInteger(int n) {
        df.setGroupingUsed(true);
        df.setGroupingSize(3);
        dfs.setGroupingSeparator('.');
        df.setDecimalFormatSymbols(dfs);

        return df.format(n);
    }
}

Related

  1. getFormat()
  2. getFormat(int decimals)
  3. getFormat(int nbDecimale)
  4. getFormatedInt(int maxValue)
  5. getFormatedPrice(BigDecimal price)
  6. getFormattedNumber(int number)
  7. getFormattedNumber(NumberFormat numberFormat, String fieldValue, Class valueClass)
  8. getFormattedNumber(String input)
  9. getFormattedQuantity(String qty, int len, String pad)