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
- locale — A java.util object naming a language and optionally a country and variant, used to format text, numbers and dates for that audience.
Taught in
- Checked, Unchecked, Catch And Finally — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Exceptions, Arrays And Collections — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Locales, Resource Bundles And Formatting — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: I/O And Localization — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep