<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);
     }

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

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

      if (integer == 0)
       Result = "零圓";
      /*
       *     貨幣整數(shù)部分操作
       *     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;
      }
      /*
       *  貨幣小數(shù)部分操作
       */
      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 閱讀(994) 評論(0)  編輯  收藏 所屬分類: java

    導航

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

    統(tǒng)計

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案(17)

    文章分類(86)

    收藏夾(3)

    flex blog

    good site

    java blog

    my friend

    tools

    抓蝦

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲白色白色在线播放| 亚洲国产精品久久久久久| 亚洲图片一区二区| 国产日韩AV免费无码一区二区 | 日本黄页网址在线看免费不卡| 国产黄在线观看免费观看不卡| 最近免费中文在线视频| 国产免费人成视频在线观看| 亚洲国产精品乱码一区二区 | 亚洲免费二区三区| 亚洲第一页在线视频| 51精品视频免费国产专区| 亚洲图片中文字幕| 中文无码成人免费视频在线观看| 亚洲五月综合缴情在线观看| 日本高清免费观看| 噜噜噜亚洲色成人网站∨| 国产91色综合久久免费| 亚洲中文字幕无码中文字| 日韩高清在线免费观看| 亚洲美女视频一区| 97无码免费人妻超级碰碰碰碰 | 蜜芽亚洲av无码精品色午夜| 成人免费一区二区三区| 性一交一乱一视频免费看| 久久亚洲熟女cc98cm| 最新欧洲大片免费在线| 春暖花开亚洲性无区一区二区| 国产亚洲精品国看不卡| 2019中文字幕免费电影在线播放| 狠狠色香婷婷久久亚洲精品| 亚洲AV永久无码精品一区二区国产| 中文字幕不卡免费视频| 亚洲大尺码专区影院| 亚洲人成无码网WWW| 99精品视频在线观看免费专区| 亚洲色婷婷六月亚洲婷婷6月| 69av免费观看| 亚洲国产成人AV在线播放| 亚洲精品成人无码中文毛片不卡| 成人免费黄色网址|