NumberFormat nf = NumberFormat.getPercentInstance(); System.out.println(nf.format(0.47)); 显示:47% DecimalFormat df1 = new DecimalFormat("##.00%"); //##.00% 百分比格式,后面不足2位的用0补齐 System.out.println(df1.format(fen)); 显示:47.00%
NumberFormat nf = NumberFormat.getPercentInstance(); System.out.println(nf.format(0.47)); 显示:47% DecimalFormat df1 = new DecimalFormat("##.00%"); //##.00% 百分比格式,后面不足2位的用0补齐 System.out.println(df1.format(fen)); 显示:47.00%