数字格式化

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	  double d_one = 56.0000; 
	  double d_kk = 0.2;
	  
	  DecimalFormat df = new DecimalFormat("#.00%");
	  
	  NumberFormat nf = NumberFormat.getInstance();
	  nf.setMaximumFractionDigits(3);
	  nf.setMinimumFractionDigits(2);
	  
	  String s_one = nf.format(d_one);
	  String s_kk = df.format(d_kk);
	  
	  String kanl = df.format(d_one);
	  
	    System.out.println(s_one);//56.00
	  
		System.out.println(kanl);//5600.00%
		
		System.out.println(s_kk);//20.00%
	}

 

你可能感兴趣的:(数字格式化)