<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大小寫 中文轉換

    public class Test {
     /*
      *  <p>Description: 字符串處理的公共類</p>
      *  <p>Copyright 2006 </p>
      *  @author  leonards
      *  @Create Date : 2006-11-23
      */

     /*
      *  將字符串轉換成中文的大寫貨幣值
      *  @param   moneyStr
      *  @return
      */
     public static String convertToCapitalMoney(String moneyStr) {
      double money = 0;
      try {
       money = Double.parseDouble(moneyStr);
      } catch (Exception e) {

      }
      return convertToCapitalMoney(money);
     }

     /*
      *  將數字轉換成中文的大寫貨幣值
      *  @param   moneyValue
      *  @return
      */
     public static String convertToCapitalMoney(double moneyValue) {
      double money = moneyValue + 0.005; //  防止浮點數四舍五入造成誤差
      String Result = "";
      String capitalLetter = "零壹貳叁肆伍陸柒捌玖";
      String moneytaryUnit = "分角圓拾佰仟萬拾佰仟億拾佰仟萬拾佰仟億拾佰仟";
      String tempCapital, tempUnit;

      int integer; //  錢的整數部分
      int point; //  錢的小數部分
      int tempValue; //  錢的每一位的值
      integer = (int) money;
      point = (int) (100 * (money - (float) integer));

      if (integer == 0)
       Result = "零圓";
      /*
       *     貨幣整數部分操作
       *     1.    依次取得每一位上的值
       *     2.    轉換成大寫
       *     3.    確定貨幣單位
       */
      for (int i = 1; integer > 0; i++) {
       tempValue = (integer % 10);
       tempCapital = capitalLetter.substring(tempValue, tempValue + 1);
       tempUnit = moneytaryUnit.substring(i + 1, i + 2);
       Result = tempCapital + tempUnit + Result;
       integer = integer / 10;
      }
      /*
       *  貨幣小數部分操作
       */
      tempValue = (point / 10);
      for (int i = 1; i > -1; i--) {
       tempCapital = capitalLetter.substring(tempValue, tempValue + 1);
       tempUnit = moneytaryUnit.substring(i, i + 1);
       Result = Result + tempCapital + tempUnit;
       tempValue = point % 10;
      }
      return Result;
     }

     public static void main(String[] args) {

      String money1 = Test.convertToCapitalMoney("400000000.215");
      System.out.println(money1);
      String money = Test.convertToCapitalMoney(40000000.215);
      System.out.println(money);
     }

    }

    posted on 2007-04-23 16:23 leoli 閱讀(985) 評論(0)  編輯  收藏 所屬分類: java

    導航

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    統計

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案(17)

    文章分類(86)

    收藏夾(3)

    flex blog

    good site

    java blog

    my friend

    tools

    抓蝦

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲av午夜福利精品一区| 亚洲天堂中文字幕在线| 亚洲AV日韩AV永久无码久久| yellow视频免费看| 亚洲日本一区二区三区在线不卡| 粉色视频成年免费人15次| 波多野结衣免费视频观看| 亚洲av无码一区二区三区四区| 免费毛片网站在线观看| 亚洲国产精品网站在线播放| 日本免费观看网站| 免费中文字幕视频| 亚洲日本中文字幕天堂网| 99精品免费视品| 亚洲视频在线观看网址| 成年人视频免费在线观看| 亚洲日韩一区二区三区| 免费国产小视频在线观看| yellow视频免费看| 亚洲视频一区调教| 成年免费大片黄在线观看岛国| 亚洲AV无码AV吞精久久| 免费在线观看a级毛片| 精精国产www视频在线观看免费| 亚洲AV中文无码字幕色三| 无码国产精品一区二区免费虚拟VR| 亚洲人成人77777在线播放| 午夜免费福利网站| jizz免费一区二区三区| 久久精品亚洲中文字幕无码麻豆 | 色吊丝性永久免费看码| 亚洲欧洲日产国码av系列天堂| 91av视频免费在线观看| 亚洲精品精华液一区二区| 国产亚洲美日韩AV中文字幕无码成人| 嫩草成人永久免费观看| 亚洲综合国产成人丁香五月激情| 亚洲成av人片天堂网老年人| 最近中文字幕免费完整| 日韩成人精品日本亚洲| 亚洲国产高清人在线|