熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

將一個BigDecimal類型的數轉換成中文

2013-11-15 11:52:13  來源: JSP教程 

  public class toChinese
  {
  public toChinese()
  {
  }
  
  public static String ConvetC(BigDecimal bds)
  {
  String strZero = ;
  String strYuan = ;
  String strJiao = ;
  String strFen = ;
  String strZheng = ;
  String strItem[] = { ?? !! **};//萬
  String strC[]={ };
  String strB[]={ };
  
  String strChinese = new String();
  String strSource = bdstoString();
  String[] strDesk;
  String strPrec = new String();
  int i = j = iNumber = iPrec = iItem = iLoc = ;
  iNumber = strSourceindexOf();
  strPrec = strSourcesubstring(iNumber+);
  //Systemoutprintln(strPrec);
  iPrec = strSourcelength() iNumber ;
  
  iItem = (int)((iNumber+)/);
  strDesk = new String[iItem];
  //Systemoutprintln( iNumber = + iNumber + iPrec = + iPrec + iItem = + iItem);
  
  for(i=; i<iItem; i++)
  {
  iLoc = (iNumber * i) > ? : (iNumber * i);
  //Systemoutprintln( iNumber = + iNumber + iPrec = + iPrec + iItem = + iItem + iLoc = + iLoc);
  strDesk[i] = ;
  int iNowItem[] = { };
  for(j= (i*)+iLoc; j> (i*) ; j)
  {
  iNowItem[ji*] = (int)(strSourcecharAt(iNumber j ));
  //Systemoutprintln(ji* +   + strSourcecharAt(iNumber j ) + + j);
  
  }
  strDesk[i] = strItem[i];
  //Systemoutprintln(strDesk[i]);
  if(iNowItem[]>)
  {
  strDesk[i] = strC[iNowItem[]] + strB[] + strDesk[i];
  }
  
  if(iNowItem[]>)
  {
  strDesk[i] = strC[iNowItem[]] + strB[] + strDesk[i];
  }
  else if(iNowItem[]== && iNowItem[]> )
  {
  strDesk[i] = strZero + strDesk[i];
  }
  
  if(iNowItem[]>)
  {
  strDesk[i] = strC[iNowItem[]] + strB[] + strDesk[i];
  }
  else if(iNowItem[]== && iNowItem[]> )
  {
  strDesk[i] = strZero + strDesk[i];
  }
  
  if(iNowItem[]>)
  {
  strDesk[i] = strC[iNowItem[]] + strB[] + strDesk[i];
  }
  else if(iNowItem[]== && iNowItem[]> )
  {
  strDesk[i] = strZero + strDesk[i];
  }
  if(iNowItem[]==&&iNowItem[]==&&iNowItem[]==&&iNowItem[]==)
  {
  strDesk[i] = strZero;
  if(i==)
  {
  strDesk[i] = ;
  }
  else if (strDesk[i]equals() || strDesk[i]indexOf(strZero)==)
  {
  strDesk[i] = ;
  }
  }
  strChinese = strDesk[i] + strChinese ;
  }
  strChinese = strChinese + strYuan;
  
  int iJiao= iFen=;
  try
  {
  iJiao = (int)(strPreccharAt());
  }
  catch(Exception e)
  {
  }
  try
  {
  iFen = (int)(strPreccharAt());
  }
  catch(Exception e)
  {
  }
  if(iJiao>)
  {
  strChinese = strChinese + strC[iJiao] + strJiao ;
  }
  if(iFen>)
  {
  strChinese = strChinese + strC[iFen] + strFen ;
  }
  else
  strChinese = strChinese + strZheng ;
  //Systemoutprintln(strChinese);
  return(strChinese);
  }
  public static void main(String[] args)
  {
  BigDecimal bdtest = new BigDecimal();
  Systemoutprintln(toChineseConvetC(bdtest));
  }
  
  }
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19781.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.