1. import java.text.NumberFormat; 
  2. import java.text.DecimalFormat; 
  3. import java.util.Locale; 
  4.  
  5. /** 
  6. * Created by IntelliJ IDEA. 
  7. * 
  8. * @author sun
  9. */ 
  10. public class TestNumFormat { 
  11.  
  12.         public static void main(String[] args) { 
  13.  
  14.                 DecimalFormat df1 = new DecimalFormat("###.00"); 
  15.                 System.out.println(df1.format(234234.234634)); 
  16.                 System.out.println(df1.format(34.234634)); 
  17.  
  18.                 DecimalFormat df2 = new DecimalFormat("0.00E0000"); 
  19.                 System.out.println(df2.format(23423.34234234)); 
  20.  
  21.                 DecimalFormat df3 = (DecimalFormat)NumberFormat.getInstance(Locale.CHINESE); 
  22.                 df3.applyPattern("####.000"); 
  23.                 System.out.println(df3.format(23423.34234234)); 
  24.                 df3.applyPattern("00.0000%"); 
  25.                 System.out.println(df3.format(0.5552445)); 
  26.  
  27.                 NumberFormat nf1 = NumberFormat.getInstance(); 
  28.                 System.out.println(nf1.format(13423423.234234)); 
  29.  
  30.                 NumberFormat nf2 = NumberFormat.getPercentInstance(); 
  31.                 System.out.println(nf2.format(0.55)); 
  32.  
  33.         }