public final class Currency extends Object implements Format
Currency 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 currency.
|
| Constructor and Description |
|---|
Currency()
Create currency formatter with default locale settings.
|
Currency(Locale locale)
Create currency formatter for given locale settings.
|
| Modifier and Type | Method and Description |
|---|---|
String |
format(Object value)
Format numeric value as currency representation using locale settings.
|
Object |
parse(String value)
Parse localized currency and return its numeric value.
|
private NumberFormat numberFormat
public Currency()
public Currency(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 class. This
method returns null if given value argument is null or empty.parse in interface Formatvalue - locale currency value.Number instance or null if value argument is null or empty.ParseException - if value argument is not a valid currency accordingly this formatter locale.Copyright © 2018. All rights reserved.