服务周到的微网站建设wordpress地理定位
news/
2025/9/22 15:59:19/
文章来源:
服务周到的微网站建设,wordpress地理定位,一键生成app软件下载,吴江做招聘的网站精简jdk包帖子“ 紧凑数字格式出现在JDK 12中 ”演示了对JDK 12中 NumberFormat的支持#xff0c;以支持紧凑数字格式 。 该帖子中显示的示例仅使用NumberFormat的实例#xff0c;这些实例是通过调用NumberFormat的新重载getCompactNumberInstance(-)方法返回的#xff0c;因… 精简jdk包 帖子“ 紧凑数字格式出现在JDK 12中 ”演示了对JDK 12中 NumberFormat的支持以支持紧凑数字格式 。 该帖子中显示的示例仅使用NumberFormat的实例这些实例是通过调用NumberFormat的新重载getCompactNumberInstance(-)方法返回的因此没有指定诸如最小小数位和最大小数位之类的特性 。 在某些情况下结果不理想。 幸运的是 NumberFormat确实允许指定最小和最大小数位并且本文演示了如何改善JDK 12提供的紧凑数字格式的输出。 原始“ 紧凑型数字格式来到JDK 12 ”一文 可在GitHub上找到 中介绍的代码清单已更新以演示NumberFormat.setMinimumFractionDigitsint的使用 。 接下来是该代码的摘录然后是随附的输出。 /*** Generates standardized map of labels to Compact Number Format* instances described by the labels. The instances of {code NumberFormat}* are created with Locale and Style only and with the provided number* of minimum fractional digits.** return Mapping of label to an instance of a Compact Number Format* consisting of a Locale, Style, and specified minimum number of fractional* digits that is described by the label.*/
private static MapString, NumberFormat generateCompactNumberFormats(final int minimumNumberFractionDigits)
{var numberFormats generateCompactNumberFormats();numberFormats.forEach((label, numberFormat) -numberFormat.setMinimumFractionDigits(minimumNumberFractionDigits));return numberFormats;
}/*** Demonstrates compact number formatting in a variety of locales* and number formats against the provided {code long} value and* with a minimum fractional digits of 1 specified.* param numberToFormat Value of type {code long} that is to be* formatted using compact number formatting and a variety of* locales and number formats and with a single minimal fractional* digit.*/
private static void demonstrateCompactNumberFormattingOneFractionalDigitMinimum(final long numberToFormat)
{final MapString, NumberFormat numberFormats generateCompactNumberFormats(1);out.println(Demonstrating Compact Number Formatting on long numberToFormat with 1 minimum fraction digit:);numberFormats.forEach((label, numberFormat) -out.println(\t label : numberFormat.format(numberToFormat)));
}Demonstrating Compact Number Formatting on long 15 with 1 minimum fraction digit:Default: 15US/Long: 15UK/Short: 15UK/Long: 15FR/Short: 15FR/Long: 15DE/Short: 15DE/Long: 15IT/Short: 15IT/Long: 15
Demonstrating Compact Number Formatting on long 150 with 1 minimum fraction digit:Default: 150US/Long: 150UK/Short: 150UK/Long: 150FR/Short: 150FR/Long: 150DE/Short: 150DE/Long: 150IT/Short: 150IT/Long: 150
Demonstrating Compact Number Formatting on long 1500 with 1 minimum fraction digit:Default: 1.5KUS/Long: 1.5 thousandUK/Short: 1.5KUK/Long: 1.5 thousandFR/Short: 1,5 kFR/Long: 1,5 millierDE/Short: 1.500DE/Long: 1,5 TausendIT/Short: 1.500IT/Long: 1,5 mille
Demonstrating Compact Number Formatting on long 15000 with 1 minimum fraction digit:Default: 15.0KUS/Long: 15.0 thousandUK/Short: 15.0KUK/Long: 15.0 thousandFR/Short: 15,0 kFR/Long: 15,0 milleDE/Short: 15.000DE/Long: 15,0 TausendIT/Short: 15.000IT/Long: 15,0 mila
Demonstrating Compact Number Formatting on long 150000 with 1 minimum fraction digit:Default: 150.0KUS/Long: 150.0 thousandUK/Short: 150.0KUK/Long: 150.0 thousandFR/Short: 150,0 kFR/Long: 150,0 milleDE/Short: 150.000DE/Long: 150,0 TausendIT/Short: 150.000IT/Long: 150,0 mila
Demonstrating Compact Number Formatting on long 1500000 with 1 minimum fraction digit:Default: 1.5MUS/Long: 1.5 millionUK/Short: 1.5MUK/Long: 1.5 millionFR/Short: 1,5 MFR/Long: 1,5 millionDE/Short: 1,5 Mio.DE/Long: 1,5 MillionIT/Short: 1,5 MlnIT/Long: 1,5 milione
Demonstrating Compact Number Formatting on long 15000000 with 1 minimum fraction digit:Default: 15.0MUS/Long: 15.0 millionUK/Short: 15.0MUK/Long: 15.0 millionFR/Short: 15,0 MFR/Long: 15,0 millionDE/Short: 15,0 Mio.DE/Long: 15,0 MillionenIT/Short: 15,0 MlnIT/Long: 15,0 milioni 如上面的示例和输出所示使用NumberFormat.setMinimumFractionDigits(int)可以生成紧凑的数字格式输出在许多情况下从美学角度来看这种输出可能会更令人满意。 OpenJDK core-libs-dev邮件列表上最近有一个讨论“ 紧凑数字格式和小数位数 ”该讨论还讨论了自定义紧凑数字格式输出的功能。 翻译自: https://www.javacodegeeks.com/2019/01/usingfractional-digits-compact-number.html精简jdk包
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/909558.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!