September 2019
Intermediate to advanced
816 pages
18h 47m
English
Starting with JDK 12, a new class for compact number formatting was added. This class is named java.text.CompactNumberFormat. The main goal of this class is to extend the existing Java number formatting API with support for locale and compaction.
A number can be formatted into a short style (for example, 1000 becomes 1K) or into a long style (for example, 1000 becomes 1 thousand). These two styles were grouped in the Style enum as SHORT and LONG.
Besides the CompactNumberFormat constructor, CompactNumberFormat can be created via two static methods that are added to the NumberFormat class:
public static NumberFormat getCompactNumberInstance() ...