Feb 19

The NumberFormat and DecimalFormat classes provide support for parsing and formatting currency values.

For example to parse a string containing a money value in the default locale you can use the following.

   NumberFormat format = NumberFormat.getCurrencyInstance();
   Object value = format.parse("$5.45");

written by objects \\ tags: , , , , ,

Feb 16

The NumberFormat class provides support for currency formatting. By current default Locale is used to determine what currency the value should be formatted in.

double value = 6.34;
NumberFormat formatter = NumberFormat.getCurrencyInstance();
String formatted = formatter.format(value);

written by objects \\ tags: , , ,