小数格式与 string.format

发布于 2024-10-05 18:54:54 字数 84 浏览 0 评论 0原文

Java 5 中引入了 string.format,十进制格式现在是否已过时?我很难找到可以用十进制格式做但不能用 string.format 做的事情。

With string.format introduced in Java 5, is decimalformat now obsolete? I'm having a hard time finding something you can do in decimalformat that you can't do in string.format.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

季末如歌 2024-10-12 18:54:54

使用十进制格式是更好的选择,因为它有区域设置和其他内容

Using decimalformat is preferable as it have Locale and other stuff

西瑶 2024-10-12 18:54:54

String.format 是静态方法调用,但您可以创建 DecimalFormat 实例并重用以前指定的格式。

String.format is a static method call but you can create a DecimalFormat instance and reuse a previously specified format.

雨夜星沙 2024-10-12 18:54:54

有一些东西,例如自动 Promilles 和货币符号替换。但是,通过适当的本地化,您可以做得更好。

There is some stuff like automatic promilles and currency symbol substitution. But it is nothing that you can't do better with proper localisation of your own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文