Compact Number Formatting and Fraction Digits

Scott Palmer swpalmer at
Thu Jan 17 14:50:17 UTC 2019

Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?

> On Jan 17, 2019, at 5:13 AM, Nishit Jain <nishit.jain at> wrote:
> Hi Gunnar,
> Currently there is no way to obtain the below expected behavior (to get 1K) when min fraction digit is set to non-zero value. I think that is not even expected when min fraction digits is set, but considering the objective of compact number formatting this could be a good value add to introduce an API which if set, truncates trailing fractional zeros while formatting output. This may need some thought process on its feasibility.
> Regards,
> Nishit Jain
> On 17-01-2019 14:37, Gunnar Morling wrote:
>> Hi,
>> I took a look at the compact number formatting recently added in JDK 12.
>> There's setMinimumFractionDigits() to control the number of fractional
>> digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
>> it also will format 1,000 as 1.0K. Is there a way to have fractional
>> digits but remove trailing zeros, so that 1,500 and 1,000 would be
>> formatted as 1.5K and 1K, respectively?

More information about the core-libs-dev mailing list