java技術博客

          jsp博客
          數據加載中……
          FormateValue.java
          /**
          *通過這個程序,測試格式器的使用方法
          */
          import java.text.NumberFormat;
          import java.util.locale;
          public class FormateValue{
          public static void main(String[] args){
          double x=100000.0/3;
          System.out.println("the value is :"+x);
          //首先以默認地區的格式器來輸出
          System.out.println("接下來輸出的是美國地區的格式器的結果:");
          NumberFormat number=NumberFormat.getNumberInstance(Locale.US);
          NumberFormat number=NumberFormat.getCurrencyInstance(Locale.US);
          NumberFormat percent=NumberFormat.getPercentInstance(Locale.US);


          FormatValue fm=new FormatValue();
          fm.print(number,x);
          fm.print(currency.x);
          fm.print(percent,x);

          System.out.println("接下來輸出的是默認地區的格式器的結果:");
          NubmerFormat nu=NumberFormat.getNumberInstance();
          NubmerFormat cu=NumberFormat.getCurrencyInstance();
          NubmerFormat be=NumberFormat.getPercentIntstance();
          fm.print(nu,x);
          fm.print(cu,x);
          fm.print(pe,x);
          }
          public void print(NubmerFormat nu,double x){
          System.out.println(nu.format(x));
          }
          }

          posted on 2008-10-22 13:21 郭興華 閱讀(182) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 盐城市| 策勒县| 磐安县| 高阳县| 康保县| 旬邑县| 壶关县| 舟曲县| 固镇县| 景东| 闵行区| 肥乡县| 明水县| 屯留县| 上杭县| 蒙自县| 嫩江县| 遂宁市| 扎囊县| 青川县| 邵阳县| 武胜县| 郁南县| 新兴县| 岗巴县| 施甸县| 金塔县| 临泽县| 酒泉市| 华坪县| 伊川县| 宣武区| 武山县| 东兴市| 桐柏县| 霍城县| 贵溪市| 铜川市| 邳州市| 子长县| 永吉县|