Hi Stephen,
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.
Regards,
Nishit Jain
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.* -
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/DateTimeFormatterBuilder.html#appendText(java.time.temporal.TemporalField,java.util.Map)
Stephen
On Fri, 16 Nov 2018 at 17:56, Nishit Jain <nishit.j...@oracle.com> wrote:
Hi,
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
Formats.
http://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
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.
Regards,
Nishit Jain