Formatting Currency Values with NumberFormat
During each iteration of the loop, line 26
NumberFormat.getCurrencyInstance().format(amount)
evaluates as follows:
1. First, the expression uses NumberFormat
’s static
method getCurrencyInstance to get a NumberFormat
that’s pre-configured to format numeric values as locale specific currency String
s—for example, in the U.S. locale, the numeric value 1628.89 is formatted as $1,628.89. Locale-specific formatting is an important part of internationalization—the process of customizing your applications for users’ various locales and spoken languages.
2. Next, the expression invokes method NumberFormat
method format (on the object returned by getCurrencyInstance
) to perform ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.