<i18n dev> RFR 8177552: Compact Number Formatting support
nishit.jain at oracle.com
Wed Nov 21 06:38:07 UTC 2018
Thanks for the comments.
The NumberFormat.Style class just defines two styles and currently it is
only used by CompactNumberFormat, making it a top level class would
require it to be more general purpose and increases the scope. In which
case evolving it at a later point of time would bea risk. The current
inner NumberFormat.Style has the scope narrow to NF and poses less risk.
Regarding providing control of the compact patterns or text, a user can
use the CNF constructor and define its own compact patterns/text for
that instance, compact NumberFormatProvider can also be used to to get
the customized CNF instance.
On 19-11-2018 19:42, Stephen Colebourne wrote:
> I'm not a big fan of having a class named `Style` as it is commonly used in
> business logic. (Yes, its an inner class, but I still think the potential
> for annoyance is high). java.time.* has `TextStyle`, but I don't think it
> can be reused here. Maybe the class should be honest and called
> NumberFormatStyle (as a top level class).
> More generally, the API does not allow the caller to take control of the
> text, for example to use "mil" as a suffix for million. eg Think of this
> method in java.time.* -
> On Fri, 16 Nov 2018 at 17:56, Nishit Jain <nishit.jain at oracle.com> wrote:
>> Please review this non trivial feature addition to NumberFormat API.
>> The existing NumberFormat API provides locale based support for
>> formatting and parsing numbers which includes formatting decimal,
>> percent, currency etc, but the support for formatting a number into a
>> human readable or compact form is missing. This RFE adds that feature to
>> format a decimal number in a compact format (e.g. 1000 -> 1K, 1000000 ->
>> 1M in en_US locale) , which is useful for the environment where display
>> space is limited, so that the formatted string can be displayed in that
>> limited space. It is defined by LDML's specification for Compact Number
>> RFE: https://bugs.openjdk.java.net/browse/JDK-8177552
>> Webrev: http://cr.openjdk.java.net/~nishjain/8177552/webrevs/webrev.00/
>> CSR: https://bugs.openjdk.java.net/browse/JDK-8188147
>> Request to please help review the the change.
>> Nishit Jain
More information about the core-libs-dev