NumberFormat

The java.text class whose factory methods format and parse numbers, currency and percentages for a locale.

In more detail

getInstance, getCurrencyInstance, getPercentInstance and getCompactNumberInstance return formatters; NumberFormat itself is abstract. parse reads from the start of the text and stops at the first character it cannot use. Grouping and decimal separators differ by locale.

Example

NumberFormat.getPercentInstance(Locale.US).format(0.256) // 26%

Related terms

Taught in

References

Certification courses