Mar*_*tos 21
"%07.2f"
Run Code Online (Sandbox Code Playgroud)
这是您需要的代码:
float myNumber = 43.4;
DecimalFormat formatter = new DecimalFormat("0000.00"); //use # for optional digits instead of 0
System.out.println(formatter.format(myNumber));
Run Code Online (Sandbox Code Playgroud)