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 郭興華 閱讀(181) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 黑河市| 南华县| 泸定县| 蛟河市| 元阳县| 睢宁县| 原阳县| 葵青区| 天长市| 长岛县| 新晃| 无为县| 丰城市| 诸暨市| 洮南市| 大庆市| 霍州市| 明水县| 淮南市| 天祝| 吐鲁番市| 巩留县| 山东| 水富县| 临沭县| 富裕县| 阿坝| 沙坪坝区| 惠安县| 玛曲县| 谷城县| 拜泉县| 松滋市| 顺义区| 罗山县| 无极县| 松原市| 平舆县| 绥阳县| 神木县| 通州区|