As with the previous phrase on formatting numbers, here we make use of the NumberFormat class, but this time to format a currency value. We use the getCurrencyInstance() of the NumberFormat class to get a currency formatting instance of the class. Using this instance, we can pass a floating point value and it will return a formatted currency value. The output of the phrase shown will be the following string: $567,123,678.99 In addition to placing commas in the appropriate places, the currency formatter also automatically adds the dollar sign character preceding the string. |