Here you can find the source of formatInt(final int number)
Parameter | Description |
---|---|
number | a parameter |
public static String formatInt(final int number)
//package com.java2s; /**/*from w w w . j a v a 2 s .c om*/ * Generic utility class. * <p/> * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License. To * view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/us/ or send a letter to Creative * Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. * * @author $Author: jal55 $ * @version $Rev: 8005 $ * @package edu.psu.iam.cpr.core.util * @lastrevision $Date: 2013-09-11 08:47:10 -0400 (Wed, 11 Sep 2013) $ */ import java.text.DecimalFormat; public class Main { /** * Pattern for pretty-formatting an int/long */ private static final String INTEGER_PATTERN = "###,###,###,##0"; /** * Format a 'int' number with default pattern * * @param number * @return contains the string representation. */ public static String formatInt(final int number) { String result = null; DecimalFormat df = new DecimalFormat(INTEGER_PATTERN); try { result = df.format(number); } catch (ArithmeticException ae) { } return result; } }