<i id='H0qgR'><tr id='H0qgR'><dt id='H0qgR'><q id='H0qgR'><span id='H0qgR'><b id='H0qgR'><form id='H0qgR'><ins id='H0qgR'></ins><ul id='H0qgR'></ul><sub id='H0qgR'></sub></form><legend id='H0qgR'></legend><bdo id='H0qgR'><pre id='H0qgR'><center id='H0qgR'></center></pre></bdo></b><th id='H0qgR'></th></span></q></dt></tr></i><div id='H0qgR'><tfoot id='H0qgR'></tfoot><dl id='H0qgR'><fieldset id='H0qgR'></fieldset></dl></div>
          <bdo id='H0qgR'></bdo><ul id='H0qgR'></ul>
        <tfoot id='H0qgR'></tfoot>

        <small id='H0qgR'></small><noframes id='H0qgR'>

      1. <legend id='H0qgR'><style id='H0qgR'><dir id='H0qgR'><q id='H0qgR'></q></dir></style></legend>

        如何用点格式化双精度?

        时间:2023-09-29
        <tfoot id='Ydgbs'></tfoot>

        <small id='Ydgbs'></small><noframes id='Ydgbs'>

          • <i id='Ydgbs'><tr id='Ydgbs'><dt id='Ydgbs'><q id='Ydgbs'><span id='Ydgbs'><b id='Ydgbs'><form id='Ydgbs'><ins id='Ydgbs'></ins><ul id='Ydgbs'></ul><sub id='Ydgbs'></sub></form><legend id='Ydgbs'></legend><bdo id='Ydgbs'><pre id='Ydgbs'><center id='Ydgbs'></center></pre></bdo></b><th id='Ydgbs'></th></span></q></dt></tr></i><div id='Ydgbs'><tfoot id='Ydgbs'></tfoot><dl id='Ydgbs'><fieldset id='Ydgbs'></fieldset></dl></div>
            <legend id='Ydgbs'><style id='Ydgbs'><dir id='Ydgbs'><q id='Ydgbs'></q></dir></style></legend>

              • <bdo id='Ydgbs'></bdo><ul id='Ydgbs'></ul>
                    <tbody id='Ydgbs'></tbody>

                • 本文介绍了如何用点格式化双精度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何将带有 String.format 的 Double 格式化为在整数和小数部分之间加点​​的字符串?

                  How do I format a Double with String.format to String with a dot between the integer and decimal part?

                  String s = String.format("%.2f", price);
                  

                  以上格式只用逗号:",".

                  The above formats only with a comma: ",".

                  推荐答案

                  String.format(String, Object ...) 正在使用您的 JVM 的默认语言环境.您可以使用 String.format(Locale, String, Object ...)java.util.Formatter 直接.

                  String.format(String, Object ...) is using your JVM's default locale. You can use whatever locale using String.format(Locale, String, Object ...) or java.util.Formatter directly.

                  String s = String.format(Locale.US, "%.2f", price);
                  

                  String s = new Formatter(Locale.US).format("%.2f", price);
                  

                  // do this at application startup, e.g. in your main() method
                  Locale.setDefault(Locale.US);
                  
                  // now you can use String.format(..) as you did before
                  String s = String.format("%.2f", price);
                  

                  // set locale using system properties at JVM startup
                  java -Duser.language=en -Duser.region=US ...
                  

                  这篇关于如何用点格式化双精度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 jTextArea(或其他类型的控制台)中保留命令 下一篇:使用 String.format() 打印空格

                  相关文章

                  最新文章

                  1. <tfoot id='5LLvb'></tfoot>
                  2. <i id='5LLvb'><tr id='5LLvb'><dt id='5LLvb'><q id='5LLvb'><span id='5LLvb'><b id='5LLvb'><form id='5LLvb'><ins id='5LLvb'></ins><ul id='5LLvb'></ul><sub id='5LLvb'></sub></form><legend id='5LLvb'></legend><bdo id='5LLvb'><pre id='5LLvb'><center id='5LLvb'></center></pre></bdo></b><th id='5LLvb'></th></span></q></dt></tr></i><div id='5LLvb'><tfoot id='5LLvb'></tfoot><dl id='5LLvb'><fieldset id='5LLvb'></fieldset></dl></div>
                  3. <legend id='5LLvb'><style id='5LLvb'><dir id='5LLvb'><q id='5LLvb'></q></dir></style></legend>
                    • <bdo id='5LLvb'></bdo><ul id='5LLvb'></ul>

                    1. <small id='5LLvb'></small><noframes id='5LLvb'>