Buglet - buglet.sourceforge.org

org.buglet.util
Class NumberUtil

java.lang.Object
  |
  +--org.buglet.util.NumberUtil

public class NumberUtil
extends java.lang.Object

Converts the given number to a String, padding with extra decimals where required.


Constructor Summary
NumberUtil()
           
 
Method Summary
static java.lang.String commafy(java.lang.String val)
           
static java.lang.String commafy(java.lang.String val, java.lang.String separator)
          generate a string representation of a number and place commas in between.
static java.lang.String forDisplay(double value, int decimalPlaces)
          Converts a double to a String, adds the given number of decimalPlaces.
static java.lang.String forDisplay(float value, int decimalPlaces)
          Converts a float to a String, adds the given number of decimalPlaces.
static java.lang.String forDisplay(java.lang.Float value, int decimalPlaces)
           
static java.lang.String forDisplay(int value, int decimalPlaces)
          Converts an int to a String, adds the given number of decimalPlaces.
static java.lang.String forDisplay(long value, int decimalPlaces)
          Converts a long to a String, adds the given number of decimalPlaces.
static java.lang.String forDisplay(java.lang.String valueString, int decimalPlaces)
          Converts the valueString to a String padded with the given number of decimalPlaces.
static java.lang.String leftSide(java.lang.String val)
          Returns the part of the String left of the decimal place.
static void main(java.lang.String[] args)
          main class used for testing the util
static int minNotNegative(int one, int two)
          Returns the non-negative minimum of two numbers min(-1,2) -> 2 min(3,4) -> 3
static java.lang.String rightSide(java.lang.String val)
          Returns the part of the String right of the decimal place
static java.lang.String roundedString(double val)
           
static java.lang.String trunctuate(java.lang.String val, int decimalPlaces)
          Returns the String, trunctuated to the given number of decimal places.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtil

public NumberUtil()
Method Detail

forDisplay

public static java.lang.String forDisplay(int value,
                                          int decimalPlaces)
Converts an int to a String, adds the given number of decimalPlaces.
Parameters:
value -  
decimalPlaces -  

forDisplay

public static java.lang.String forDisplay(long value,
                                          int decimalPlaces)
Converts a long to a String, adds the given number of decimalPlaces.
Parameters:
value -  
decimalPlaces -  

forDisplay

public static java.lang.String forDisplay(float value,
                                          int decimalPlaces)
Converts a float to a String, adds the given number of decimalPlaces.
Parameters:
value -  
decimalPlaces -  

forDisplay

public static java.lang.String forDisplay(java.lang.Float value,
                                          int decimalPlaces)

forDisplay

public static java.lang.String forDisplay(double value,
                                          int decimalPlaces)
Converts a double to a String, adds the given number of decimalPlaces.
Parameters:
value -  
decimalPlaces -  

forDisplay

public static java.lang.String forDisplay(java.lang.String valueString,
                                          int decimalPlaces)
Converts the valueString to a String padded with the given number of decimalPlaces.
Parameters:
valueString -  
decimalPlaces -  

leftSide

public static java.lang.String leftSide(java.lang.String val)
Returns the part of the String left of the decimal place.
Parameters:
val -  

commafy

public static java.lang.String commafy(java.lang.String val)

commafy

public static java.lang.String commafy(java.lang.String val,
                                       java.lang.String separator)
generate a string representation of a number and place commas in between.

rightSide

public static java.lang.String rightSide(java.lang.String val)
Returns the part of the String right of the decimal place
Parameters:
val -  

trunctuate

public static java.lang.String trunctuate(java.lang.String val,
                                          int decimalPlaces)
Returns the String, trunctuated to the given number of decimal places. trunctuate("3.0324", 2) -> "3.03 trunctuate("3.2", 4) -> "3.2000"
Parameters:
val -  
decimalPlaces -  

minNotNegative

public static int minNotNegative(int one,
                                 int two)
Returns the non-negative minimum of two numbers min(-1,2) -> 2 min(3,4) -> 3
Parameters:
one -  
two -  

roundedString

public static java.lang.String roundedString(double val)

main

public static void main(java.lang.String[] args)
main class used for testing the util
Parameters:
args -  

Buglet - buglet.sourceforge.org

Copyright © 2001 58k.com Inc. All Rights Reserved