欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

关于数字千分位和带两位小数的显示,数字千分两位小数

来源: javaer 分享于  点击 599 次 点评:112

关于数字千分位和带两位小数的显示,数字千分两位小数


[java] view plain copy
String str = DecimalFormat.getNumberInstance().format(1245600000);  
[java] view plain copy
  
[java] view plain copy
DecimalFormat df = new DecimalFormat("0.00");  
[java] view plain copy
  
[java] view plain copy
  
[java] view plain copy
<span >  /**</span>  
[java] view plain copy
  
[java] view plain copy
 * 格式化数字为千分位显示 要格式化的数字  
 * @param  
 * @return  
 */  
public static String fmtMicrometer(String text)  
{  
    DecimalFormat df = null;  
    if(text.indexOf(".") > 0)  
    {  
        if(text.length() - text.indexOf(".")-1 == 0)  
        {  
            df = new DecimalFormat("###,##0.00");//0.00  
        }else if(text.length() - text.indexOf(".")-1 == 1)  
        {  
            df = new DecimalFormat("###,##0.00");//0.00  
        }else  
        {  
            df = new DecimalFormat("###,##0.00");//0.00  
        }  
    }else  
    {  
        df = new DecimalFormat("###,##0.00");//0.00  ###,##0  
    }  
    double number = 0.00;  
    try {  
        number = Double.parseDouble(text);  
    } catch (Exception e) {  
        number = 0.00;  
    }  
    return df.format(number);  
}  
  
  
* public static String fmtMicrometer(String text)  
{  
    DecimalFormat df = null;  
    if(text.indexOf(".") > 0)  
    {  
        if(text.length() - text.indexOf(".")-1 == 0)  
        {  
            df = new DecimalFormat("###,##0.");//0.00  
        }else if(text.length() - text.indexOf(".")-1 == 1)  
        {  
            df = new DecimalFormat("###,##0.0");//0.00  
        }else  
        {  
            df = new DecimalFormat("###,##0.00");//0.00  
        }  
    }else  
    {  
        df = new DecimalFormat("###,##0");//0.00  ###,##0  
    }  
    double number = 0.0;  
    try {  
        number = Double.parseDouble(text);  
    } catch (Exception e) {  
        number = 0.0;  
    }  
    return df.format(number);  
}*/  



相关文章

    暂无相关文章
相关栏目:

用户点评