decimalformatdemo.java

来自「JAVA 工作指南 可以说是程序员必备的东西哦」· Java 代码 · 共 20 行

JAVA
20
字号
import java.text.*;public class DecimalFormatDemo {   static public void customFormat(String pattern, double value ) {      DecimalFormat myFormatter = new DecimalFormat(pattern);      String output = myFormatter.format(value);      System.out.println(value + "  " + pattern + "  " + output);   }   static public void main(String[] args) {      customFormat("###,###.###", 123456.789);      customFormat("###.##", 123456.789);      customFormat("000000.000", 123.78);      customFormat("$###,###.###", 12345.67);     }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?