currency format problem with bigdecimal values

Hi Guys

I have a problem to format bigdecimal values to currency format with the Java methode Decimalformat.

input is: 2345678901234567890.123457 after methode below we return the formatted value: 2'345'678'901'234'567'700.000000

Is it possible that methode "DecimalFormat" has a problem with bigdecimal values? Do you have a hint or a solution for this problem?

DecimalFormatSymbols dfs = new DecimalFormatSymbols();

dfs.setGroupingSeparator('\'');

DecimalFormat df = new DecimalFormat("###,###,###,###,###.000000", dfs);

String formattedNumberFormat = df.format( bigdecimalValue );

System.out.println(formattedNumberFormat);

Thanks for your help

Robert

[731 byte] By [szhqvo] at [2007-9-30 18:48:25]
# 1

Yeah, it appears that there are internal limits in the DecimalFormat code. I wasn't able to make any approach work. I see (by viewing the source) that the class has a 64-bit length limit to the formattable number, and yours is greater.

I suggest that you create your own formatter class for these very large numbers using the String class methods - mostly substring, indexOf, and replace methods. It shouldn't be too hard.

ChuckBing at 2007-7-6 21:05:37 > top of Java-index,Administration Tools,Sun Connection...