简体   繁体   中英

Java DecimalFormat output with dot separator

I use Decimalformat two get two decimals with this line of code

DecimalFormat df = new DecimalFormat("#0.00");

My outputs is for example like this

568,99  
1090,33
12897,45
233567,77

How can I set the decimalformat to output like this?

568,99  
1.090,33
12.897,45
233.567,77

Is there a way with the methods from Decimalformat to do this. With codes like these

 df.setMinimumFractionDigits(3);
 df.setMaximumFractionDigits(3);
 df.setMinimumIntegerDigits(1);

I never extended my knowledge about DecimalFormat, that's why I'm asking.

  1. Is this possible to do with the decimalformat code? How?

  2. Is there a better way?

I realized it does not look nice with the dots. Look here for example.

1.234.345,00

So I changed to empty space instead with this line...

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

that created this

1 234 345,00

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