in JAVA by
Q:
Compact Number Formatting JAVA 12 feature

1 Answer

0 votes
by

import java.text.NumberFormat;

import java.util.Locale;

public class CompactNumberFormatting {

    public static void main(String[] args)

    {

        System.out.println("Compact Formatting is:");

        NumberFormat upvotes = NumberFormat

                .getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.SHORT);

        upvotes.setMaximumFractionDigits(1);

        System.out.println(upvotes.format(2592) + " upvotes");

        NumberFormat upvotes2 = NumberFormat

                .getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.LONG);

        upvotes2.setMaximumFractionDigits(2);

        System.out.println(upvotes2.format(2011) + " upvotes");

    }

}

 

Click here to read more about JAVA
Click here to read more about Insurance

Related questions

0 votes
asked Jan 10, 2020 in JAVA by DavidAnderson
+1 vote
asked May 27, 2019 in Other by rajeshsharma
0 votes
asked Oct 19, 2020 in JAVA by rahuljain1
0 votes
asked May 13, 2019 in Other by gurgaon
0 votes
0 votes
0 votes
asked Aug 25, 2020 in XML by Robindeniel
0 votes
asked Nov 14, 2019 in Continuous Integration by rajeshsharma
...