简体   繁体   中英

decimal formatting pattern in Java

I want format this number using java : 1546521.23 to 1 546 521.23 for exemple when i format this number 70000.0 it output 7 00 00

I tried this pattern but not work :

DecimalFormat decimalFormat = new DecimalFormat("### ###,##");

See the DecimalFormat documentation :

Symbol  Location    Localized?  Meaning
.       Number      Yes         Decimal separator or monetary decimal separator
,       Number      Yes         Grouping separator

Change code to

DecimalFormat decimalFormat = new DecimalFormat("### ###.##");

The comma needs to be replaced with a period.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM