|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbcds.tools.NumberFmt<K,V>
public class NumberFmt<K,V>
Formats a Number as a string, using the most simple (human) representation possible. For example, if double variable contains the value 12345.0, produces the string "12345". In this class, "integer" means any numeric value that "fits" into a long. Floating-point numbers are "printed" with the current locale.
Constructor Summary | |
---|---|
NumberFmt()
Default constructor. |
|
NumberFmt(java.lang.String float_fmt)
Creates a new instance that will format non-"integer" values with the format given in float_fmt , which must be
a valid format specifier for String.format. |
Method Summary | |
---|---|
static java.lang.String |
asString(java.lang.Number n)
Returns a string corresponding to the number n
formatted using the default format specifier. |
java.lang.String |
format(java.lang.Number n)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NumberFmt()
public NumberFmt(java.lang.String float_fmt)
float_fmt
, which must be
a valid format specifier for String.format.
Method Detail |
---|
public java.lang.String format(java.lang.Number n)
public static java.lang.String asString(java.lang.Number n)
n
formatted using the default format specifier.
It is equivalent to:
String z = new NumberFmt().format(some_value);but the object used internally is instantiated only once. This method's name should have been format, but there is already a non-static method by that name.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |