문제

I am using

DecimalFormat df = new DecimalFormat("###,###,###.##")

when trying to format numbers, but only numbers greater than seven digits get formatted with commas. So, 1000000 gets converted to 1,000,000, but 1000 does not get converted to 1,000. Is there something I am doing wrong or there is any other way to format numbers that I should use ?

도움이 되었습니까?

해결책

Try

df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));

The DecimalFormat is locale specific and can interpret format symbols differently depending on the system locale.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top