net.xoetrope.xui.helper
Class NumberFormatter

java.lang.Object
  extended by net.xoetrope.xui.helper.NumberFormatter

public class NumberFormatter
extends java.lang.Object

A utility to help format numbers in accordance with the current Locale

Copyright (c) Xoetrope Ltd., 1998-2004

$Revision: 2.2 $


Constructor Summary
NumberFormatter()
          Create a new formatter
 
Method Summary
static java.lang.String format(double input)
          Convert a double value to a string
static java.lang.String format(long input)
          Convert a long value to a string
static java.lang.String format(java.lang.Object input)
          Convert a Object (Double,Float etc) value to a string
static java.lang.String formatDouble(double input)
          Convert a double value to a string
 java.lang.String formatNumber()
          Format a number
static char getDecimalSeparator()
          Get the current decimal separator character
static java.lang.Number parse(java.lang.String input)
          Convert a string to a Number
static double parseDouble(java.lang.String input)
          Convert a string to a double value
static double parseDouble(java.lang.String input, char decimalSeparator, char groupSeparator)
          Convert a string to a double value
static float parseFloat(java.lang.String input)
          Convert a string to a float value
static int parseInt(java.lang.String input)
          Convert a string to an int value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberFormatter

public NumberFormatter()
Create a new formatter

Method Detail

formatNumber

public java.lang.String formatNumber()
Format a number

Returns:
the formatted number

parse

public static java.lang.Number parse(java.lang.String input)
Convert a string to a Number

Parameters:
input - thge input string
Returns:
the Number object

parseDouble

public static double parseDouble(java.lang.String input)
Convert a string to a double value

Parameters:
input - the input string representation of the number
Returns:
the numeric value

parseDouble

public static double parseDouble(java.lang.String input,
                                 char decimalSeparator,
                                 char groupSeparator)
Convert a string to a double value

Parameters:
input - the input string representation of the number
Returns:
the numeric value

parseInt

public static int parseInt(java.lang.String input)
Convert a string to an int value

Parameters:
input - the input string representation of the number
Returns:
the numeric value

parseFloat

public static float parseFloat(java.lang.String input)
Convert a string to a float value

Parameters:
input - the input string representation of the number
Returns:
the numeric value

getDecimalSeparator

public static char getDecimalSeparator()
Get the current decimal separator character

Returns:
the decimal separator

format

public static java.lang.String format(double input)
Convert a double value to a string

Parameters:
input - the input numeric value
Returns:
the string representation of the number

formatDouble

public static java.lang.String formatDouble(double input)
Convert a double value to a string

Parameters:
input - the input numeric value
Returns:
the string representation of the number

format

public static java.lang.String format(long input)
Convert a long value to a string

Parameters:
input - the input numeric value
Returns:
the string representation of the number

format

public static java.lang.String format(java.lang.Object input)
Convert a Object (Double,Float etc) value to a string

Parameters:
input - the input numeric value
Returns:
the string representation of the number