uk.ac.ed.inf.utils
Class NumberUtils

java.lang.Object
  extended by uk.ac.ed.inf.utils.NumberUtils

public class NumberUtils
extends java.lang.Object

Class

Version:
22 Jan 2009
Author:
Luna De Ferrari luna.deferrari-at-ed.ac.uk

Constructor Summary
NumberUtils()
           
 
Method Summary
static java.lang.String doubleTo2DecimalsString(java.lang.Double aDouble)
          Get a percentage representation of a double
static java.lang.String formatPercentOneFraction(double num)
          Takes a double in percent returns a String with one fraction 0.85842 -> 85.8%
static java.lang.String getValue(java.lang.Double value)
          Gets a string value usable for SQL DOUBLE column.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtils

public NumberUtils()
Method Detail

doubleTo2DecimalsString

public static java.lang.String doubleTo2DecimalsString(java.lang.Double aDouble)
Get a percentage representation of a double

Parameters:
fraction - e.g. 0.75
Returns:
a percentage, e.g. 75% public static String getPercentage(Double fraction){ Double percent = new Double(fraction); NumberFormat percentFormatter = NumberFormat.getPercentInstance(Locale.getDefault()); return percentFormatter.format(percent); }

formatPercentOneFraction

public static java.lang.String formatPercentOneFraction(double num)
Takes a double in percent returns a String with one fraction 0.85842 -> 85.8%


getValue

public static java.lang.String getValue(java.lang.Double value)
Gets a string value usable for SQL DOUBLE column. The string must be either double precision numeric or null: NaN or +/-inf are not acceptable values.

Parameters:
the - value
Returns:
the double precision value string or null if = NaN or = +/-inf