码迷,mamicode.com
首页 > 编程语言 > 详细

java工具类 --千分位方法

时间:2015-07-10 18:13:35      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

/**
* 千分位方法
* @param text
* @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.");
}else if(text.length() - text.indexOf(".")-1 == 1)
{
df = new DecimalFormat("###,##0.0");
}else
{
df = new DecimalFormat("###,##0.00");
}
}else
{
df = new DecimalFormat("###,##0");
}
double number = 0.0;
try {
number = Double.parseDouble(text);
} catch (Exception e) {
number = 0.0;
}
return df.format(number);
}

java工具类 --千分位方法

标签:

原文地址:http://www.cnblogs.com/qingfengliaoren/p/4636161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!