JAVA_IIBRARY Telegram 1380
Начиная с JDK 12, появилась новая фича — java.text.CompactNumberFormat. Она позволяет компактно отображать большие числа

Пример:

Locale.setDefault(Locale.US);
NumberFormat compact = NumberFormat.getCompactNumberInstance();

System.out.println(compact.format(1));
System.out.println(compact.format(999));
System.out.println(compact.format(2_000));
System.out.println(compact.format(55_555));
System.out.println(compact.format(3_777_999));
System.out.println(compact.format(Integer.MAX_VALUE));


Вывод:

1
999
2K
56K
4M
2B


Также доступен стиль LONG:

NumberFormat compact;
compact = NumberFormat.getCompactNumberInstance(Locale.US, Style.LONG);


Результат:

1
999
2 thousand
56 thousand
4 million
2 billion


Идеально для UI, отчетов и всего, где важна краткость 💖

👉 Java Portal
Please open Telegram to view this post
VIEW IN TELEGRAM



tgoop.com/Java_Iibrary/1380
Create:
Last Update:

Начиная с JDK 12, появилась новая фича — java.text.CompactNumberFormat. Она позволяет компактно отображать большие числа

Пример:

Locale.setDefault(Locale.US);
NumberFormat compact = NumberFormat.getCompactNumberInstance();

System.out.println(compact.format(1));
System.out.println(compact.format(999));
System.out.println(compact.format(2_000));
System.out.println(compact.format(55_555));
System.out.println(compact.format(3_777_999));
System.out.println(compact.format(Integer.MAX_VALUE));


Вывод:

1
999
2K
56K
4M
2B


Также доступен стиль LONG:

NumberFormat compact;
compact = NumberFormat.getCompactNumberInstance(Locale.US, Style.LONG);


Результат:

1
999
2 thousand
56 thousand
4 million
2 billion


Идеально для UI, отчетов и всего, где важна краткость 💖

👉 Java Portal

BY Java Portal | Программирование


Share with your friend now:
tgoop.com/Java_Iibrary/1380

View MORE
Open in Telegram


Telegram News

Date: |

In handing down the sentence yesterday, deputy judge Peter Hui Shiu-keung of the district court said that even if Ng did not post the messages, he cannot shirk responsibility as the owner and administrator of such a big group for allowing these messages that incite illegal behaviors to exist. On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression." The court said the defendant had also incited people to commit public nuisance, with messages calling on them to take part in rallies and demonstrations including at Hong Kong International Airport, to block roads and to paralyse the public transportation system. Various forms of protest promoted on the messaging platform included general strikes, lunchtime protests and silent sit-ins. Select “New Channel” Activate up to 20 bots
from us


Telegram Java Portal | Программирование
FROM American