<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 閱讀(995) 評論(0)  編輯  收藏 所屬分類: java

    導航

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    統計

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案(17)

    文章分類(86)

    收藏夾(3)

    flex blog

    good site

    java blog

    my friend

    tools

    抓蝦

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 永久免费不卡在线观看黄网站| 中文字幕乱码亚洲无线三区| 丰满人妻一区二区三区免费视频| 日本不卡视频免费| 亚洲6080yy久久无码产自国产 | 亚洲日韩精品射精日| 一边摸一边爽一边叫床免费视频| 免费jjzz在在线播放国产| 亚洲一区在线免费观看| h视频在线免费看| 丁香亚洲综合五月天婷婷| 亚洲精品国产品国语在线| 麻豆狠色伊人亚洲综合网站| 97视频热人人精品免费| 亚洲人AV在线无码影院观看| 黄网址在线永久免费观看 | 一本到卡二卡三卡免费高| 久久久久亚洲AV成人网| 在线观看免费播放av片| 久久亚洲日韩看片无码| 无码免费午夜福利片在线| 亚洲av无码成人影院一区| 亚洲麻豆精品国偷自产在线91| 中文字幕成人免费高清在线| 亚洲综合在线观看视频| 青青久在线视频免费观看| 日本久久久久亚洲中字幕| 国产99视频精品免费观看7| 麻豆69堂免费视频| 亚洲国产精品无码久久SM| 黄在线观看www免费看| 色偷偷尼玛图亚洲综合| 亚洲色成人WWW永久网站| 1000部啪啪未满十八勿入免费| 亚洲国产精品无码久久98| 中国人xxxxx69免费视频| 欧美激情综合亚洲一二区| 亚洲区小说区激情区图片区| 91频在线观看免费大全| 日日躁狠狠躁狠狠爱免费视频| 亚洲av无码一区二区乱子伦as |