November 2006
Intermediate to advanced
224 pages
3h 29m
English
double value = 1623542.765; NumberFormat numberFormatter; String formattedValue; numberFormatter = NumberFormat.getNumberInstance(); formattedValue = numberFormatter.format(value); System.out.format("%s%n", formattedValue); |
In most applications, there is a need to display numbers. Fortunately, Java has built-in support for formatting numbers so that they will look as you want them to when you display them in your application.
This phrase will generate the following formatted number as output:
1,623,542.765
In this phrase, we use the NumberFormat class to format a double value into a comma separated string representation of its value. The NumberFormat class is found in the java.text package and is also very useful for code that ...
Read now
Unlock full access