double one= Double.parseDouble(1+"");
double two= Double.parseDouble(2+"");
double percent = one/ two;
//獲取格式化對象
NumberFormat nt = NumberFormat.getPercentInstance();
//設置百分數精確度2即保留兩位小數
nt.setMinimumFractionDigits(2);
//最後格式化並輸出
System.out.println("百分數:" + nt.format(percent));