|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.format.NumberFormatter
public class NumberFormatter
Formats numbers into localized Strings for display. This class relies heavily on the NumberFormat and DecimalFormat classes in the java.text package, and it is suggested that you become familiar with those classes before using custom formats.
Accepts the following named formatTypes (not case sensitive):
If a format type is not supplied the default value of "number" will be used. Format String can be either a custom pattern as used by NumberFormat, or one of the following named formats (not case sensitive):
Field Summary | |
---|---|
protected static Set<String> |
namedPatterns
Maintains a set of named formats that can be used instead of patterns. |
Constructor Summary | |
---|---|
NumberFormatter()
|
Method Summary | |
---|---|
String |
format(Number input)
Formats the number supplied as a String. |
String |
getFormatPattern()
Gets the named format string or number format pattern to use to format the number. |
String |
getFormatType()
Gets the format type to be used to render numbers as Strings. |
Locale |
getLocale()
Gets the locale that output String should be in. |
void |
init()
Instantiates the NumberFormat based on the information provided through setter methods. |
void |
setFormatPattern(String formatPattern)
Sets the named format string or number format pattern to use to format the number. |
void |
setFormatType(String formatType)
Sets the format type to be used to render numbers as Strings. |
void |
setLocale(Locale locale)
Sets the locale that output String should be in. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Set<String> namedPatterns
Constructor Detail |
---|
public NumberFormatter()
Method Detail |
---|
public void setFormatType(String formatType)
setFormatType
in interface Formatter<Number>
public String getFormatType()
public void setFormatPattern(String formatPattern)
setFormatPattern
in interface Formatter<Number>
public String getFormatPattern()
public void setLocale(Locale locale)
setLocale
in interface Formatter<Number>
public Locale getLocale()
public void init()
init
in interface Formatter<Number>
public String format(Number input)
format
in interface Formatter<Number>
input
- an object of a type that the formatter knows how to format
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |