Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pattern for Decimal Format

Tags:

java

I would like to translate 10000000.0 to PREFIX10,000,000.00

May I know what pattern I should pass into DecimalFormat?

NumberFormat numberFormat = new DecimalFormat(...);
numberFormat.format(10000000.0);
like image 272
Cheok Yan Cheng Avatar asked Apr 19 '26 04:04

Cheok Yan Cheng


1 Answers

new DecimalFormat("PREFIX#,##0.00");

This will always show at least one integer digit (e.g. 0), and use comma as group separator.

like image 63
Matthew Flaschen Avatar answered Apr 21 '26 18:04

Matthew Flaschen