1

I'm writing unit tests for a method that formats some numbers and when I use DecimalFormat("¤#,##0") it always prefixes  in the unit tests. It does not display the  in the XML output file that the numbers are written to, but it does in the unit tests. For example:

DecimalFormat decimalFormat = new DecimalFormat("¤#,##0");
String str = decimalFormat.format(5000);

The XML output file will hold the value $5,000, but when I debug or unit test str = "Â$5,000"

Is this expected behavior or is something wrong? The DecimalFormat documentation (http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html) says that,

Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator.

I understand that it is probably getting the currency symbol from the default locale, but why does the  show up?

If it is expected behavior great, I'll just use the replace method, but if it is not expected I want to figure out what is going on.

Nick L
  • 281
  • 1
  • 6
  • 18
  • 2
    Where does it display wrong ? This could well be a terminal encoding issue. – Quentin Aug 14 '15 at 15:19
  • Could it be something like a interpreted BOM or any other non printable character? – keuleJ Aug 14 '15 at 15:49
  • On the very next line of code after `String str = decimalFormat.format(5000);` the string is getting added as a value to a particular element in an xml object. When I assert the value of that element I get the Â$5,000, but like I said, when view the fully built XML the value is $5,000. – Nick L Aug 14 '15 at 16:13

0 Answers0