org.ijsberg.iglu.util.formatting
Class NumberFormatter

java.lang.Object
  extended by org.ijsberg.iglu.util.formatting.NumberFormatter

public class NumberFormatter
extends Object

Formats any float-like value to a displayable string. Performs rounding if necessary. Trailing zeroes are, if necessary, returned to fill up the desired number of decimals.


Constructor Summary
NumberFormatter(char decimalSymbol, char digitGroupingSymbol)
           
 
Method Summary
 String format(BigDecimal number, int nrofDecimals)
           
 String format(double number, int nrofDecimals)
           
 String format(float number, int nrofDecimals)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberFormatter

public NumberFormatter(char decimalSymbol,
                       char digitGroupingSymbol)
Parameters:
decimalSymbol - character that separates decimals
digitGroupingSymbol - symbol that groups 3 digits
Method Detail

format

public String format(float number,
                     int nrofDecimals)
Parameters:
number - number to format
nrofDecimals - desired number of decimals
Returns:
the formatted number

format

public String format(double number,
                     int nrofDecimals)
Parameters:
number - number to format
nrofDecimals - desired number of decimals
Returns:
the formatted number

format

public String format(BigDecimal number,
                     int nrofDecimals)
Parameters:
number - number to format
nrofDecimals - desired number of decimals
Returns:
the formatted number


Copyright © 2011. All Rights Reserved.