public final class Percent extends Object implements Format
Percent formatter implementation is based on Java NumberFormat that is not synchronized. Therefore this
implementation is not thread safe.
| Modifier and Type | Field and Description |
|---|---|
private NumberFormat |
numberFormat
Formatter for percent.
|
| Constructor and Description |
|---|
Percent()
Create percent formatter with default locale settings.
|
Percent(Locale locale)
Create percent formatter for given locale settings.
|
| Modifier and Type | Method and Description |
|---|---|
String |
format(Object value)
Format numeric value as percent representation using locale settings.
|
Object |
parse(String value)
Parse percent from given string value and return it as
Number instance. |
private NumberFormat numberFormat
public Percent()
public Percent(Locale locale)
locale - locale settings.public String format(Object value)
value
argument is null.format in interface Formatvalue - numeric value.IllegalArgumentException - if value argument is not an instance of Number.public Object parse(String value) throws ParseException
Number instance. Given string value
should have a numeric part and percent sign and should respect this formatter locale. Returns null if
value argument is null or empty.parse in interface Formatvalue - percent value.Number instance, possible null if value argument is null or empty.ParseException - if value is not formated as percent.Copyright © 2018. All rights reserved.